PDA

View Full Version : problem loading Combobox value in a form with Json nested Object.



Manuelvm
15 Jun 2012, 10:24 AM
i have aproblem loading a Combobox value in a form with Json nested Object.


when i do



myForm.getForm().load({
url: 'Requisition/GetRequisition',
params: {
reqID: data
},
failure: function (form, action) {
Ext.Msg.alert("Load failed", action.result.errorMessage);
}
});
i receive a Json string like this:





{"success":true,"data":{"reqNumber":8,"requisitor":"Jerry.Gomez","reqDepartment":{"id":5,"name":"Department 05"},"requestDateString":"2012/06/14","projectCustomer":{"id":10,"name":"Customer 06"},"project":{"projectID":7,"name":"Project 07"},"itemQuantity":0,"lastReqNumber":0}}


which is supossed to go to a form with several comboboxes that are supossed to change the display values to those their just received from the load, theese combobox values were already prepopulated from a store.


the thing is that i have a combobox which is receiving the value: "requisitor":"Jerry.Gomez" which shows into the combobox display value but there is other comboboxes that receive nested objects like: "reqDepartment":{"id":5,"name":"Department 05"}, which i have no idea how to make them show for display value, here is my code for the comboboxes.


this one is the one that works fine


var requestorReq_combo = Ext.create('Ext.form.field.ComboBox', {
id: 'requestorReqCmb',
store: usersAdCombo_store,
name: 'requisitor',
hiddenName: 'username',
valueField: 'username',
displayField: 'concat_name',
label: 'Requestor', fieldLabel: 'Requestor',
allowBlank: false, blankText: msgFldReq_, emptyText: msgCmbDefault_, selected: 0,
typeAhead: true, mode: 'local', forceSelection: true, triggerAction: 'all', selectOnFocus: true,
width: 220
});




and this one that isnt displaying the values.



var departmentReq_combo = Ext.create('Ext.form.field.ComboBox', {
id: 'departmentReqCmb',
name: 'reqDepartment.id',
store: departmentCombo_store,
hiddenName: 'id',
valueField: 'id',
displayField: 'name',
label: 'Department', fieldLabel: 'Department',
allowBlank: false, blankText: msgFldReq_, emptyText: msgCmbDefault_, selected: 0,
typeAhead: true, mode: 'local', forceSelection: true, triggerAction: 'all', selectOnFocus: true,
width: 220
});




i had a similar case for stores that loaded values into a grid, i used a mapping tag into the model to read the nested objects, but since im not using a model into the form, i have no idea on how to do it.


sorry if i didnt quite explained myself in here im a begginer with ExtJS.