商店未定义

发布于 2024-11-14 22:19:09 字数 2849 浏览 2 评论 0原文

我在 ExtJS 上遇到这个问题。我创建了一个显示在窗口上的网格,它将从外部服务器端脚本获取 json 数据。它工作得很粗暴,但萤火虫一直告诉我,我在网格中的列上单击的所有内容都未定义商店。你能帮我解决这个问题吗?这是我的代码:

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();
                    }
                }],

谢谢。

I have this problem on ExtJS. I created a grid that display on a window, it will get json data from an external server side script. It is rougly working but the firebug keeps telling me that store is undefined everything I click on the columns in the grid. Can you please help me solve this. Here is my code:

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();
                    }
                }],

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

扶醉桌前 2024-11-21 22:19:09

更改您的商店声明...

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

Change your store declaration...

var jsonstore = new Ext.data.JsonStore({
    autoDestroy: true,
    fields: fields,
    root: 'candidates',
    idProperty: 'Name',
    url: createRefTo,
    autoLoad: true
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文