Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/403.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

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
Javascript 全选-在Ext JS组合框中选择无_Javascript_Extjs_Combobox - Fatal编程技术网

Javascript 全选-在Ext JS组合框中选择无

Javascript 全选-在Ext JS组合框中选择无,javascript,extjs,combobox,Javascript,Extjs,Combobox,根据对这个问题的回答: 我已经用ExtJS中的“全选”和“全选”实现了我自己的组合框 但是,如果我不止一次地使用它,这些操作将应用于所有实例。只需在一个组合中单击“全选/全选”,您将看到其他更改的方式: 对于最初的答案,我得到了同样的错误行为: 如果您能帮助我解决此问题,我将不胜感激。我认为使用me.container.on就是问题所在 根据您的示例,我尝试了一种不同的方法,先听展开,然后听picker元素单击,它似乎可以工作: listeners: { expand: {

根据对这个问题的回答:

我已经用ExtJS中的“全选”和“全选”实现了我自己的组合框

但是,如果我不止一次地使用它,这些操作将应用于所有实例。只需在一个组合中单击“全选/全选”,您将看到其他更改的方式:

对于最初的答案,我得到了同样的错误行为:


如果您能帮助我解决此问题,我将不胜感激。

我认为使用
me.container.on
就是问题所在

根据您的示例,我尝试了一种不同的方法,先听
展开
,然后听picker元素单击,它似乎可以工作:

listeners: {
    expand: {
        single: true,
        fn: function () {
            var me = this,
                flabel = this.getFieldLabel();

            me.picker.on({
                click: {
                    element: 'el',
                    fn: function (e) {
                        var el = e.getTarget('div', 3, true);

                        if (el.getAttribute('action') == 'select-all') {
                            me.select(me.getStore().getRange());
                            me.setSelectedCount(me.getStore().getRange().length, flabel);
                            allSelected = true;
                        } else if (el.getAttribute('action') == 'select-none') {
                            me.reset();
                            allSelected = false;
                        }
                    }
                }
            });
        }
    }
}
一个有效的例子:

listeners: {
    expand: {
        single: true,
        fn: function () {
            var me = this,
                flabel = this.getFieldLabel();

            me.picker.on({
                click: {
                    element: 'el',
                    fn: function (e) {
                        var el = e.getTarget('div', 3, true);

                        if (el.getAttribute('action') == 'select-all') {
                            me.select(me.getStore().getRange());
                            me.setSelectedCount(me.getStore().getRange().length, flabel);
                            allSelected = true;
                        } else if (el.getAttribute('action') == 'select-none') {
                            me.reset();
                            allSelected = false;
                        }
                    }
                }
            });
        }
    }
}