PDA

View Full Version : CheckBoxGroup + loadRecord + remote store



netsuo
7 Nov 2011, 5:27 AM
Hi,

I've been having headaches about one problem I have.

I have a form that contains a CheckBoxGroup like that:



{
width: 'auto',
name: 'vision_color_id',
xtype: 'checkboxgroup',
fieldLabel: 'Valeurs',
columns: [.25,.25,.25,.25],
items:
[
{
xtype: 'checkbox',
boxLabel: 'Label 1',
name: 'color_1'
},
{
xtype: 'checkbox',
boxLabel: 'Label 2',
name: 'color_2'
},
{
xtype: 'checkbox',
boxLabel: 'Label 1',
name: 'color_2'
}
]
}


My data is formatted like this:


{
"field1": "blah",
"vision_color_id":"{color_1: true, color_2: true}"
}


In my store I just have a field named "vision_color_id".

When I use loadRecord, my checkboxes are not checked. If I'm adding a "convert" function (or a custom data type) and just do "Ext.decode(vision_color_id)" in my convert function, the checkboxes are checked but after loadRecord, isDirty return true.

What's the method to return checkbox values in a store without having a store field for each checkbox ?

mitchellsimoens
18 Nov 2011, 11:59 AM
If you have your JSON returned like this it *should* work:


{
"field1": "blah",
"vision_color_id": {
"color_1": true,
"color_2": true
}
}

Notice the value of "vision_color_id" is now an Object and not a String and the keys in the Object have the double-quotes.