惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
宝玉的分享
宝玉的分享
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
J
Java Code Geeks
腾讯CDC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Engineering at Meta
Engineering at Meta
L
LangChain Blog
Jina AI
Jina AI
博客园 - 叶小钗
B
Blog RSS Feed
Recent Announcements
Recent Announcements
H
Help Net Security
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
B
Blog
云风的 BLOG
云风的 BLOG
Blog — PlanetScale
Blog — PlanetScale
D
DataBreaches.Net
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
罗磊的独立博客

博客园 - lwjacky

SQL提高查询效益之in、not in、between、like等条件讲述 sqlserver查询数据的所有表名和行数 Extjs4---Cannot read property 'addCls' of null Sql 脚本文件太大 系统操作日志设计 一种简单的直观的高效的权限设计 ExtJs 常用方法 属性 C#农历类 通过C#使用googleAPI SQL SERVER 如何批量修改表和存储过程的架构 HTML特殊转义字符列表 - lwjacky - 博客园 extjs3.0 修正 ie 与 firefox字体显示差异的补丁 C#实现QQ接口软件--QQ的HTTP接口协议探究 二次开发WinWebMail邮件系统接口 C#实现汉字转换为拼音缩写的代码 C#实现将汉字转化为拼音的代码 extjs IE8下datefield的width问题 ExtJS中如何给Label添加click事件 自己的工具箱(Toolkit)
ExtJs4.1实现数据缓存
lwjacky · 2013-11-06 · via 博客园 - lwjacky

Ext.onReady(function () {

            Ext.define("ProvinceCity", {

                extend: "Ext.data.Model",

                fields: [

                { name: "ProvinceName", type: "string" },

                { name: "CityName", type: "string" }

                ]

            });

            var store = Ext.create("Ext.data.Store", {

                model: "ProvinceCity",

                //autoLoad: true,//进行手动加载

                proxy: {

                    type: "ajax",

                    url: "test2.aspx",

                    reader: {

                        type: "xml",

                        record: "Table"

                    }

                }

            });

            var data;

            var dataStore = new Array();

            store.load({

                scope: this,

                callback: function (records, operation, success) {

                    data = store.collect("ProvinceName"); //因为省份有重复的选项,要把其中重复的选项去掉

                    Ext.Array.each(data, function (item) {

                        dataStore.push({ 'ProvinceName': item });

                    });

                }

            });

            var store1 = Ext.create("Ext.data.Store", {

                fields: ["ProvinceName"],

                data: dataStore,

                proxy: {

                    type: "memory"

                }

            });

            var store2 = Ext.create("Ext.data.Store", {

                model: "ProvinceCity",

                proxy: {

                    type: "memory"

                }

            });

            Ext.create("Ext.form.Panel", {

                id: "form1",

                renderTo: Ext.getBody(),

                bodyPadding: 10,

                width: "auto",

                title: "Please Choose Province And City",

                layout: {

                    type: "hbox",

                    align: "left"

                },

                items: [

                        { xtype: "combobox", id: "provinceName", fieldLabel: "ProvinceName", store: store1, valueField: "ProvinceName", displayField: "ProvinceName", padding: 10, listeners: { "select": function (comboBox, record, index) {

                            var temp = store.queryBy(function (record, id) {

                                if (record.get("ProvinceName") == comboBox.getValue()) {

                                    return true;

                                }

                            });

                            store2.removeAll();

                            store2.add(temp.items);

                            Ext.getCmp("cityName").clearValue();

                            Ext.getCmp("cityName").bindStore(store2);

                        }

                        }

                        },

                        { xtype: "combobox", fieldLabel: "CityName", id: "cityName",  padding: 10, valueField: "ProvinceName", displayField: "CityName"}]

            });

        });