{groupName-6ren">
gpt4 book ai didi

android - 如何将列表中的所有复选框 'check' 改为 'check' 单个复选框?

转载 作者:行者123 更新时间:2023-11-29 22:07:19 27 4
gpt4 key购买 nike

我陷入了一种情况,我必须通过“选中”工具栏中的复选框来“选中”列表中存在的所有复选框。

这是创建复选框列表的代码:-

itemTpl: '<input type="checkbox" name="box" enabled="enabled" value="open" 
name="comment_status" id="status" <tpl if="active">checked="checked"</tpl> />
{groupName}{#}',

这是我的复选框代码:-

var checkBox = {
xtype: 'checkboxfield',
name : 'all',
// label: 'All',
itemId: 'all',
value: 'all',
lableWidth: "0",
width: 1,
padding: '0 0 15 30',
checked: false,
listeners: {
check:function() {
// alert("check");

item = Ext.get("status");
console.log("item:-"+Ext.JSON.encode(item));

chkBox = item.down('input').dom;

var checkboxes = Ext.getStore('group');
console.log(checkboxes.getCount());

for(var i=0;i<checkboxes.getCount();i++){
chkBox.checked = true;
}

},
uncheck:function(){
// alert("uncheck");
}
}
};

在上面的复选框检查中,我希望检查“itemTpl”中定义的所有复选框,反之亦然。我知道检查中的代码:function(){} 不能很好地解决我的问题(两者不同 View 中的代码)。

所以,请告诉我一些解决这个问题的方法。

提前致谢。

最佳答案

好的,我更新了your senchafiddle让它工作。实际上,这是我添加到您的代码中的内容:

向您的列表 Controller 添加 2 个函数,以管理工具栏中复选框上的操作:

checkAll:function(){
this.getCheckboxList().getStore().each(function(record){record.set('active', true);});
},
uncheckAll:function(){
this.getCheckboxList().getStore().each(function(record){record.set('active', false);});
}

然后在列表上方添加带有复选框的工具栏以将它们全部统治 (XD):

   {
xtype : 'toolbar',
docked: 'top',
title: 'Check !',
items:[{
xtype: 'checkboxfield',
name : 'all',
value: 'checkAll',
listeners:{
check:function(){
MyApp.app.getController('MainViewController').checkAll();
},
uncheck:function(){
MyApp.app.getController('MainViewController').uncheckAll();
}
}
}]
}

这将需要您使用一些 css 来使 ckeckbox 漂亮,但行为就在这里。

关于android - 如何将列表中的所有复选框 'check' 改为 'check' 单个复选框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10511823/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com