PDA

View Full Version : form.updateRecord() destroys the proper format of CheckboxGroup field!



misha
29 Nov 2011, 1:28 AM
Checkbox group, named 'roles' for example, expects a value in a format:


myCheckboxGroup.setValue({
roles: ['1', '2']
});


But when form.updateRecord() is used that format is being translated to:
[true, true]

Hope this is not a feature :-) cause this format is useless on the server side, and requires conversion on both sides during client-server communication.

In any case a lot of work for nothing! Just don't change the format CheckboxGorup uses!

My work around for now is not to use form.updateRecord(), which used form.getFieldValues() but to use form.getValues() to update record by hand.

If I'm missing something any feedback would be appreciated.

mitchellsimoens
29 Nov 2011, 2:45 PM
What are the inputValues?

Also, http://www.sencha.com/forum/showthread.php?138165-How-to-report-a-bug

misha
30 Nov 2011, 6:50 AM
This is a dump of items property of checkboxgroup widget:

29701

Input values are strings '1' and '2'

alanmies
15 Oct 2013, 10:48 PM
This bug still exists at least as of ExtJS 4.2.1, a small test case below:



Ext.onReady(function() {
Ext.define('Bug', {
extend: 'Ext.data.Model',
fields: ['bug']
});

Ext.create('Ext.form.Panel', {
id: 'bugform',
items: [{
xtype: 'checkboxgroup',
id: 'bug',
vertical: true,
columns: 1,
items: [
{ name: 'bug', inputValue: 1, boxLabel: 1 },
{ name: 'bug', inputValue: 2, boxLabel: 2 },
{ name: 'bug', inputValue: 3, boxLabel: 3 }
]
}],
bbar: [{
text: 'Bugtest',
handler: function() {
console.log(Ext.getCmp('bug').getValue().bug);
Ext.getCmp('bugform').updateRecord();
console.log(Ext.getCmp('bugform').getRecord().getData().bug);
}
}],
renderTo: Ext.getBody()
}).loadRecord(Ext.create('Bug'));
});


The expected result when "Bugtest" is clicked is the first console.log, that is, an array of inputValues of checked items. But the result of using form.updateRecord() is an array of boolean values of all checkboxes, true or false depending on whether the checkbox is checked.