首页 新闻 赞助 找找看

extjs 取数据问题

0
悬赏园豆:5 [已解决问题] 解决于 2015-06-16 22:47

版本3.0

后台代码:

        public JsonResult City()
        {
            return Json("{\"data\":[{\"id\":1,\"name\":\"北京\"}]}", JsonRequestBehavior.AllowGet);
        }

js:

    Ext.onReady(function () {
        //创建市数据源
        var combocitystore = new Ext.data.Store({
            //设定读取的地址
            proxy: new Ext.data.HttpProxy({ url: 'combobox/City' }),
            //设定读取的格式    
            reader: new Ext.data.JsonReader({ root: 'data' }, [
            { name: "id" },
            { name: "name"}])
        });

        //创建市Combobox
        var comboboxcity = new Ext.form.ComboBox({
            id: 'comboboxcity',
            fieldLabel: '市',
            width: 120,
            store: combocitystore,
            displayField: 'name',
            valueField: 'id',
            triggerAction: 'all',
            emptyText: '请选择...',
            allowBlank: false,
            blankText: '请选择市',
            editable: false,
            mode: 'local', //该属性和以下方法为了兼容ie8
            listeners: {
                'render': function () {
                    combocitystore.load();
                    alert(combocitystore.getCount());
                }
            }
        });

        //----------------------下拉列表结束----------------------//
        //表单
        var form = new Ext.form.FormPanel({
            frame: true,
            title: '表单标题',
            style: 'margin:10px',
            items: [comboboxcity, comboareacity]
        });
        //窗体
        var win = new Ext.Window({
            title: '窗口',
            width: 476,
            height: 374,
            resizable: true,
            modal: true,
            closable: true,
            maximizable: true,
            minimizable: true,
            buttonAlign: 'center',
            items: form
        });
        win.show();
 ---自己写的ajax是正常的
        $.ajax({

            type: "post",
            url: 'combobox/City',
            data: null,
            dataType: "json",
            success: function (data) {
                var d = $.parseJSON(data);
            }

        });
    });

原因combocitystore 为null 是什么原因呢?

脚本无错误

s_p的主页 s_p | 初学一级 | 园豆:138
提问于:2015-05-22 18:21
< >
分享
最佳答案
0

extjs

s_p | 初学一级 |园豆:138 | 2015-06-16 22:47
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册