选择全部-在Ext JS组合框中选择无
Select all - Select none in Ext JS Combobox
根据这个问题的答案:在ExtJS 4.0组合框中选择所有
afterrender: function () {
me.container.on({
click: function(e) {
console.log('on clic called');
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;
}
}
})
}
我已经实现了我自己的组合框'选择全部'和'选择无'在Ext JS。
但是,如果我多次使用它,操作将应用于所有实例。只需尝试在一个组合中单击"选择全部/选择无",您将看到其他变化:http://jsfiddle.net/hernan666/vfbkgmmu/。
对于原始答案,我得到相同的错误行为:http://jsfiddle.net/hernan666/dFEsc/414/
我将感谢任何帮助解决这个问题
我认为使用me.container.on
是问题所在。
我尝试了一种不同的方法,根据你的例子,听expand
,然后选择器元素点击,它似乎工作:
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;
}
}
}
});
}
}
}
工作示例:http://jsfiddle.net/ot0eaqv1/
相关文章:
- 复选框选择组合
- 多个和单个选择/组合框的逻辑
- 在jquery mobile中动态选择组合框
- 从选择/组合 JavaScript 中删除节点
- 选择组合框值
- Angularjs :从列表中选择组合
- 选择组合框后显示复选框
- 编程岩石,纸张,剪刀的选择组合-Javascript
- 将数据输入和下拉选择组合到js中
- 从外部CSV文件填充选择组合框表单
- 角材质链通过从数组中选择组合,形成输入数组
- 根据文本自动选择组合框中的值
- 将输入和选择组合到一个可见的输入字段中
- ExtJS多选择组合框
- Ajax加载复选框后选择组合框- php
- 我如何在html页面中创建日期选择组合框
- 如何选择组合值,点击进入
- 选择组合框数据后的动态文本字段(编码器)
- 如何计算所有可能的选择组合
- 选择组合框值并通过隐藏字段将其发送到下一页