-
21 May 2012 10:44 PM #1
[4.1.1 RC1] Combo field was not selected with form.loadRecord() method
[4.1.1 RC1] Combo field was not selected with form.loadRecord() method
Here is the combo field:
At the first time, I will open a window to show the add form and the combo correctly selects the Male option by configuration. But when I open edit window and use the form.loadRecord() method to populate the form's fields, all are populated correctly except the combo fields, all the combo fields's text are the id value (For Gender field is 1) and not select the wanted one.Code:{ fieldLabel: 'Gender', xtype: 'combo', name: 'gender', allowBlank: false, valueField: 'id', displayField: 'value', editable: false, queryMode: 'local', triggerAction: 'all', store: Ext.create('Ext.data.ArrayStore', { fields: ['id', 'value'], data: [['1', 'Male'], ['2', 'Female']] }), value: '1' }
I also try to use this code to force select the option but failed
Any suggestions?Code:form.findField('gender').setValue(user.get('gender'));Last edited by skirtle; 25 May 2012 at 1:47 AM. Reason: Edit to make code readable
-
23 May 2012 5:16 PM #2
-
25 May 2012 1:57 AM #3
I suspect it's a type mismatch.
This works as expected:
This works the way you describe:Code:combo.setValue('2');
It's the same against 4.1.0.Code:combo.setValue(2);
-
25 May 2012 7:47 PM #4
Thanks.
Yes, it's a data format issue - the value is int in the model. I changed the codes like below and it works
Code:{ fieldLabel: 'Gender', xtype: 'combo', name: 'gender', allowBlank: false, valueField: 'id', displayField: 'value', editable: false, queryMode: 'local', triggerAction: 'all', store: Ext.create('Ext.data.ArrayStore', { fields: ['id', 'value'], data: [[1, 'Male'], [2, 'Female']] }), value: 1 }
-
25 May 2012 7:49 PM #5
BTW, It won't need to call setValue method, just call form.loadRecord method is enough.


Reply With Quote
