0

我得到检查数据字符串:“box0,box15,box30,box45”

Sencha docs 说,我可以这样设置值(复选框 id 和 name 与上面相同)

// use comma separated string to set items with name to true (checked)
myCheckboxGroup.setValue('cb-col-1,cb-col-3');

我想以这种方式设置我的盒子,但不能。你对此有什么想法吗?

4

3 回答 3

0

我不在工作,所以我无法检查我的消息来源,但我记得应该是

cb-col-1 = Ext.getCmp(cb-col-1)
cb-col-3 = Ext.getCmp(cb-col-3)

myCheckboxGroup.setValue(cb-col-1 true);
myCheckboxGroup.setValue(cb-col-3, true);

如果它是一个组件,并且

Ext.get('cb-col-1').dom.value = true;
Ext.get('cb-col-3').dom.value = true;

如果它是一个元素

于 2012-12-06T23:42:52.983 回答
0

setValue与 a 一起使用时,checkboxgroup您需要传递复选框字段名称:

Ext.create('Ext.form.CheckboxGroup', {
    id: 'MyGroup',
    items: [{
        xtype:'checkbox',
        name: 'check1'
    },{
        xtype: 'checkbox',
        name: 'check2'
    },{
        xtype: 'checkbox',
        name: 'checkset',
        inputValue: 'val1'
    },{
        xtype: 'checkbox',
        name: 'checkset',
        inputValue: 'val2'
    }]
 });

 Ext.getCmp('MyGroup').setValue({
     check1: true,
     check2: false,
     checkset: ['val1', 'val2']
 });

字面意思是从Sencha Docs中提取的

于 2013-06-18T13:38:11.147 回答
0

这应该工作:

Ext.getCmp('MyCheckboxGroup').setValue({
     cbxName: true,
     cbxDescription: false
     //cbxDescription: (condition)  //you can always specify an condition here.
 });

注意: cbxName,cbxDescription是 下的复选框的 id MyCheckboxGroup,例如:

{
    xtype: 'checkboxgroup',
    fieldLabel: 'MyCheckboxGroup',
    name: 'mycbxgrp',
    columns: 2,
    items: [
        { id: 'cbxName', boxLabel: 'Name', name: 'mycbxgrp', inputValue: 1 },
        { id: 'cbxDescription', boxLabel: 'Description', name: 'mycbxgrp', inputValue: 2 }
    ]
}
于 2014-01-10T09:03:44.587 回答