【问题标题】:ExtJS 3.4 checkboxgroup doesn't set valueExtJS 3.4 复选框组未设置值
【发布时间】:2012-12-06 14:41:22
【问题描述】:

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

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

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

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

【问题讨论】:

  • 你能发布更多代码吗?显示您对 Ext.Create 的呼叫或您的复选框组的配置

标签: extjs extjs3


【解决方案1】:

这应该有效:

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

注意:cbxNamecbxDescriptionMyCheckboxGroup 下复选框的 id,例如:

{
    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 }
    ]
}

【讨论】:

    【解决方案2】:

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

    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;
    

    如果它是一个元素

    【讨论】:

      【解决方案3】:

      当使用setValuecheckboxgroup 时,您需要传递复选框字段名称:

      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提升

      【讨论】:

      • 抱歉,没有看到 3.4 版本# - 我的回答可能完全错误。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-19
      • 1970-01-01
      相关资源
      最近更新 更多