Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.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
更改存储数据时extjs更新_Extjs_Grid - Fatal编程技术网

更改存储数据时extjs更新

更改存储数据时extjs更新,extjs,grid,Extjs,Grid,我正在使用设计器。我的目标是更新一个商店记录,到目前为止,它是通过单击newBtn启动的。我试图在调用它的函数之外执行它 如果我试着点击按钮,它会工作 /application.js Ext.Loader.setConfig({ enabled: true }); Ext.application({ name: 'MyApp', stores: [ 'MyArrayStore' ], launch: function() {

我正在使用设计器。我的目标是更新一个商店记录,到目前为止,它是通过单击newBtn启动的。我试图在调用它的函数之外执行它

如果我试着点击按钮,它会工作

/application.js

Ext.Loader.setConfig({
    enabled: true
});

Ext.application({
    name: 'MyApp',

    stores: [
        'MyArrayStore'
    ],

    launch: function() {
        Ext.QuickTips.init();

        var cmp1 = Ext.create('MyApp.view.TradeGrid', {
            renderTo: Ext.getBody()
        });

     cmp1.show();


    //PROBLEM HERE  
    // This actually does something but when maxIndex is printed to the console it = 0
    // Meaning that no data has been loaded to grid
    // Am I wrong thinking it should? As the other file loads two data cells right away

       cmp1.addRecord([]);

    //PROBLEM HERE
/TradeGrid.js

Ext.define('MyApp.view.TradeGrid', {
    extend: 'MyApp.view.ui.TradeGrid',

    initComponent: function() {
        var me = this;


        me.callParent(arguments);

        var button = me.down('button[text=newBtn]');
        button.on('click', me.onSubmitBtnClick, me);

    },

    addRecord: function(myRecordArray) {

            var grid = Ext.getCmp("TradeGrid");  //defined by  -> Property: id 
            var store = grid.getStore();

            var maxIndex = store.getCount();
            console.log(maxIndex);               //maxIndex PRINT to CONSOLE


            var res = store.insert(maxIndex, [["ll", "kk", "00"]]);


            console.log(this);

    },

    onSubmitBtnClick: function() {
        this.addRecord([]);
    }




});

        }
    });
前两个数据加载到网格中

[
["Ace Supplies", "Emma Knauer", "555-3529"],
["Best Goods", "Joseph Kahn", "555-8797"],

]

我看到您使用Ext.getCmp获取网格引用-这意味着您硬编码了组件的id。这不是一个好主意,最好尝试使用itemId。这可能会让汤姆产生一些奇怪的虫子,也许这就是你的电脑无法工作的原因。尝试将id更改为itemId。

我看到您使用Ext.getCmp获取网格引用-这意味着您硬编码了组件的id。这不是一个好主意,最好尝试使用itemId。这可能会让汤姆产生一些奇怪的虫子,也许这就是你的电脑无法工作的原因。尝试将id更改为itemId。

我最终破坏了designer生成的代码,它确实不适合WebSocket,但我现在使用的代码方式你的答案有效。我最终破坏了designer生成的代码,它确实不适合WebSocket,但我现在使用的代码方式你的答案有效。