0
votes

I get checked data string: "box0,box15,box30,box45"

Sencha docs says, I can set the value this way (checkboxes id and name are same like above)

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

I want to set true my boxes this way, but can't. Have you any idea about this?

3
Can you post more code? Show your call to Ext.Create or your config for your checkbox group - phatskat

3 Answers

0
votes

I'm not at work so i can't check my sources but i recall that it should be

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);

if it is a component, and

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

if it is an element

0
votes

When using setValue with a checkboxgroup you need to pass the checkbox field name:

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']
 });

Literally lifted from the Sencha Docs

0
votes

This should work :

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

NOTE: cbxName, cbxDescription are the id's of checkboxes under MyCheckboxGroup, eg:

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