Json 存储未定义

Json 存储未定义,json,extjs,undefined,store,jsonstore,Json,Extjs,Undefined,Store,Jsonstore,我在ExtJS上有这个问题。我创建了一个显示在窗口上的网格,它将从外部服务器端脚本获取json数据。它工作得很艰难,但firebug一直告诉我,我在网格中单击列时,存储是未定义的。你能帮我解决这个问题吗。这是我的密码: var fields = [{ name: "Name", type: "text" }, { name: "NSId", type: "number" }, { name: "Id", type: "number" }, {

我在ExtJS上有这个问题。我创建了一个显示在窗口上的网格,它将从外部服务器端脚本获取json数据。它工作得很艰难,但firebug一直告诉我,我在网格中单击列时,存储是未定义的。你能帮我解决这个问题吗。这是我的密码:

var fields = [{
    name: "Name",
    type: "text"
}, {
    name: "NSId",
    type: "number"
}, {
    name: "Id",
    type: "number"
}, {
    name: "Version",
    type: "number"
}];

var columns = [{
    header: 'Name',
    id: 'Name',
    width: 160,
    sortable: true,
    dataIndex: 'Name'
}, {
    header: 'NSId',
    id: 'NSId',
    width: 45,
    sortable: true,
    hidden: true,
    dataIndex: 'NSId'
}, {
    header: 'Id',
    id: 'Id',
    width: 30,
    sortable: true,
    hidden: true,
    dataIndex: 'Id'
}, {
    header: 'Version',
    id: 'Version',
    width: 50,
    sortable: true,
    hidden: true,
    dataIndex: 'Version'
}];

var searchAndPickUrl = OcsConfig.url.refto;
var pickerUrl = '?picker=' + config.picker;
var createRefTo = searchAndPickUrl + pickerUrl;

var jsonstore = {
    xtype: 'jsonstore',
    autoDestroy: true,
    fields: fields,
    root: 'candidates',
    idProperty: 'Name',
    url: createRefTo,
    autoLoad: true
};

var cmpGrid = null;

var clickCell = function (trigger) {
        var record = cmpGrid.getSelectionModel().getSelected();
        var selValues = record.data['name'] + ',' + record.data['nsid'] + ',' + record.data['id'] + ',' + record.data['version'];
        Ext.Msg.alert('Name', selValues);
    };

var refToGrid = {
    id: Ext.id(),
    xtype: 'grid',
    store: jsonstore,
    columns: columns,
    stripeRows: true,
    defaults: {
        anchor: '100%'
    },
    autoExpandColumn: 'Name',
    height: 350,
    width: 600,
    title: '',
    stateful: true,
    stateId: 'grid',
    listener: {
        rowdblclick: clickCell
    }
};

var refToWin = function refToInputVal(trigger) {
        var values = config.options || [];
        var cmpWin = null;
        var genId = Ext.id();
        var win = null;

        if (cmpWin === null) {
            win = {
                xtype: 'window',
                title: config.caption || '',
                modal: true,
                items: [{
                    xtype: 'form',
                    id: genId,
                    padding: 5,
                    defaults: {
                        anchor: '100%'
                    },
                    items: [refToGrid]
                }],
                bbar: [{
                    xtype: 'button',
                    text: 'OK',
                    handler: function () {
                        returnValue(trigger, cmpGrid);
                        cmpWin.hide();
                    }
                }, {
                    xtype: 'button',
                    text: 'Cancel',
                    handler: function () {
                        cmpWin.hide();
                    }
                }],

谢谢。

更改您的店铺声明

var jsonstore = new Ext.data.JsonStore({
    autoDestroy: true,
    fields: fields,
    root: 'candidates',
    idProperty: 'Name',
    url: createRefTo,
    autoLoad: true
});

更改您的店铺声明

var jsonstore = new Ext.data.JsonStore({
    autoDestroy: true,
    fields: fields,
    root: 'candidates',
    idProperty: 'Name',
    url: createRefTo,
    autoLoad: true
});

嗯。。我的计划是创建一个可配置变量,这就是为什么我使用xtypes。我可以问一下为什么我需要使用这个而不是xtypes吗。无论如何,非常感谢您的及时回复。:)这个变量
jsonstore
仍然是可重用的,ExtJS没有像您那样正确地解析它。嗯。。我的计划是创建一个可配置变量,这就是为什么我使用xtypes。我可以问一下为什么我需要使用这个而不是xtypes吗。无论如何,非常感谢您的及时回复。:)这个变量
jsonstore
仍然是可重用的,ExtJS没有像您那样正确地解析它。我看不到您所有的代码,但是使用xtypes声明ExtJS组件意味着相应的ExtJS对象只有在通过将它们添加到已经实例化的ExtJS对象的现有集合中进行实例化后才可用。我看不到您的所有代码,但是使用xtypes声明ExtJS组件意味着只有在通过将相应的ExtJS对象添加到已经实例化的ExtJS对象的现有集合中进行实例化之后,它们才可用。