Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ExtJS JsonStore未填充_C#_Json_Extjs_Sencha Touch - Fatal编程技术网

C# ExtJS JsonStore未填充

C# ExtJS JsonStore未填充,c#,json,extjs,sencha-touch,C#,Json,Extjs,Sencha Touch,我的JsonStore似乎没有被填充。当我运行代码时,它会发出请求,请求返回json。当我检查数据存储时,数据数组是空的 我错过了什么?谢谢 我定义了这个JsonStore: CCList.ListStore = new Ext.data.JsonStore({ root: 'rows', idProperty: 'Id', fields: ['Id', 'Description'], autoLoad: true, proxy: new Ext.data

我的JsonStore似乎没有被填充。当我运行代码时,它会发出请求,请求返回json。当我检查数据存储时,数据数组是空的

我错过了什么?谢谢

我定义了这个JsonStore:

CCList.ListStore = new Ext.data.JsonStore({
    root: 'rows',
    idProperty: 'Id',
    fields: ['Id', 'Description'],
    autoLoad: true,
    proxy: new Ext.data.HttpProxy({
        method: 'GET',
        url: '/costcenters/getjson'
    }),
    listeners: {
        load: function (obj, records) {
            Ext.each(records, function (rec) {
                console.log(rec.get('Id'));
            });
        }
    }
});
正在尝试将其绑定到此外部列表

CCList.listPanel = new Ext.List({
            id: 'indexList',
            store: CCList.ListStore,
            itemTpl: '<div class="costcenter">{Id}-{Description}</div>'
            }
        });

仅供参考,您没有使用ExtJS,您使用的是Sencha Touch,它们是不同的,所以您在将来澄清这一点很重要

Ext.setup({
    onReady: function(){
        Ext.regModel('CostCenter', {
            idProperty: 'Id',
            fields: ['Id', 'Description']
        });

        var store = new Ext.data.Store({
            model: 'CostCenter',
            autoLoad: true,
            proxy: {
                type: 'ajax',
                method: 'GET',
                url: 'data.json',
                reader: {
                    type: 'json',
                    root: 'rows'
                }
            },
            listeners: {
                load: function(obj, records){
                    Ext.each(records, function(rec){
                        console.log(rec.get('Id'));
                    });
                }
            }
        });

        new Ext.List({
            fullscreen: true,
            store: store,
            itemTpl: '<div class="costcenter">{Id}-{Description}</div>'
        });

    }
});
Ext.setup({
onReady:function(){
Ext.regModel(‘成本中心’{
idProperty:“Id”,
字段:['Id','Description']
});
var store=新的Ext.data.store({
型号:“成本中心”,
自动加载:对,
代理:{
键入:“ajax”,
方法:“GET”,
url:'data.json',
读者:{
键入:“json”,
根:“行”
}
},
听众:{
加载:功能(对象、记录){
Ext.each(记录、功能(rec){
console.log(rec.get('Id'));
});
}
}
});
新分机列表({
全屏:对,
店:店,,
itemTpl:“{Id}-{Description}”
});
}
});

非常感谢。那么JsonStore对Sencha Touch无效吗?它就在那里,但是数据包现在的工作方式有点多余,你最好坚持我上面概述的方法。
Ext.setup({
    onReady: function(){
        Ext.regModel('CostCenter', {
            idProperty: 'Id',
            fields: ['Id', 'Description']
        });

        var store = new Ext.data.Store({
            model: 'CostCenter',
            autoLoad: true,
            proxy: {
                type: 'ajax',
                method: 'GET',
                url: 'data.json',
                reader: {
                    type: 'json',
                    root: 'rows'
                }
            },
            listeners: {
                load: function(obj, records){
                    Ext.each(records, function(rec){
                        console.log(rec.get('Id'));
                    });
                }
            }
        });

        new Ext.List({
            fullscreen: true,
            store: store,
            itemTpl: '<div class="costcenter">{Id}-{Description}</div>'
        });

    }
});