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 渲染后如何在Ext.selection.CheckboxModel中设置选中项?_Extjs_Extjs6_Checked - Fatal编程技术网

Extjs 渲染后如何在Ext.selection.CheckboxModel中设置选中项?

Extjs 渲染后如何在Ext.selection.CheckboxModel中设置选中项?,extjs,extjs6,checked,Extjs,Extjs6,Checked,我正在Ext.grid.Panel中使用Ext.selection.CheckboxModel,并且在数据绑定和组件重新定义后,whant检查了一些项目。部件工作正常但错误的部分如下所示: listeners: { afterRender: function (thisObj, eOpts) { var window = Ext.ComponentQuery.query('#' + 'requestOperator_kbkAccess-window

我正在
Ext.grid.Panel
中使用
Ext.selection.CheckboxModel
,并且在数据绑定和组件重新定义后,whant检查了一些项目。部件工作正常但错误的部分如下所示:

    listeners: {
        afterRender: function (thisObj, eOpts) {
            var window = Ext.ComponentQuery.query('#' + 'requestOperator_kbkAccess-window')[0];
            if (window) {
                var row = window.accessGrid.getSelectionModel().getSelection()[0],
                    ppp = row.get('Ppp'),
                    codes = ppp.map(a => a.Code);

                Ext.defer(function () {
                    var selections = [];
                    codes.forEach(function (item, index) {
                        let i = thisObj.getStore().find('Code', item);
                        if (i !== -1) {
                            selections.push(store.getAt(i))
                        }
                    });

                    console.log(thisObj.getStore().data);

                    thisObj.getSelectionModel().select(selections);
                }, 100);
            }
        }
    }
此代码从父组件接收类似于
02207709
的代码字符串,并尝试在
Ext.selection.CheckboxModel
中设置为选中此代码。这段代码的错误工作是行
let i=thisObj.getStore().find('code',item)返回-1,
thisObj.getStore()中调试中的项目计数。数据
为0。但在控制台中,我看到
console.log(thisObj.getStore().data)返回预期结果:
在
viewready
上,结果相同


我是extJs新手,不明白在这个简单的功能中我做错了什么?请帮忙。谢谢。

您需要在商店加载后执行此功能:()

你可以这样做:

    listeners: {
        afterRender: function (thisObj, eOpts) {
            thisObj.getStore().on('load', function () {
                var window = Ext.ComponentQuery.query('#' + 'requestOperator_kbkAccess-window')[0];
                if (window) {
                    var row = window.accessGrid.getSelectionModel().getSelection()[0],
                        ppp = row.get('Ppp'),
                        codes = ppp.map(a => a.Code);

                    Ext.defer(function () {
                        var selections = [];
                        codes.forEach(function (item, index) {
                            let i = thisObj.getStore().find('Code', item);
                            if (i !== -1) {
                                selections.push(store.getAt(i))
                            }
                        });

                        console.log(thisObj.getStore().data);

                        thisObj.getSelectionModel().select(selections);
                    }, 100);
                }
            });
        }
    },

您需要在加载存储后执行此功能:()

你可以这样做:

    listeners: {
        afterRender: function (thisObj, eOpts) {
            thisObj.getStore().on('load', function () {
                var window = Ext.ComponentQuery.query('#' + 'requestOperator_kbkAccess-window')[0];
                if (window) {
                    var row = window.accessGrid.getSelectionModel().getSelection()[0],
                        ppp = row.get('Ppp'),
                        codes = ppp.map(a => a.Code);

                    Ext.defer(function () {
                        var selections = [];
                        codes.forEach(function (item, index) {
                            let i = thisObj.getStore().find('Code', item);
                            if (i !== -1) {
                                selections.push(store.getAt(i))
                            }
                        });

                        console.log(thisObj.getStore().data);

                        thisObj.getSelectionModel().select(selections);
                    }, 100);
                }
            });
        }
    },