1 Ext.override(Ext.form.CheckboxGroup,{
2
3 setValueForItem : function(val){ //多个选项值以逗号分开的
4 val = ","+val+","
5 this.items.each(function(item) {
6 if (val.indexOf(item.inputValue) > -1) {
7 item.setValue(true);
8 } else {
9 item.setValue(false);
10 }
11 });
12 }
13 ,clearValueForItem:function(){ //清空所有值
14 this.items.each(function(item) {
15 item.setValue(false);
16 });
17 }
18 });
2
3 setValueForItem : function(val){ //多个选项值以逗号分开的
4 val = ","+val+","
5 this.items.each(function(item) {
6 if (val.indexOf(item.inputValue) > -1) {
7 item.setValue(true);
8 } else {
9 item.setValue(false);
10 }
11 });
12 }
13 ,clearValueForItem:function(){ //清空所有值
14 this.items.each(function(item) {
15 item.setValue(false);
16 });
17 }
18 });
本文介绍了一段 ExtJS 代码,用于实现 CheckboxGroup 的值批量设置和清空功能。通过修改 Ext.form.CheckboxGroup 类,实现了 setValueForItem 方法来设置多个选项值,以及 clearValueForItem 方法来清空所有已选值。
1796

被折叠的 条评论
为什么被折叠?



