PDA

View Full Version : Extjs JsonStore combo with dubobject data.



fatnjazzy
23 Apr 2011, 9:51 PM
Hi,
For internal reasons, I have to send back from the server to the combo the following json string:


{"root":[{"employeeId":1,"user":{"userName":"admin"}}]}

As you can see, the user is actually an object, any way that the combobox will be able to read it?
the combo is configured as the following:


,displayField:'user.userName'
,title:'Manager'
,xtype: 'numberfield'
,hiddenName: 'employeeId'
,valueField : 'employeeId'

this is the store:


var store = new Ext.data.JsonStore({
autoLoad: true,
url: "/some_data",
root: 'root',
methos:'POST',
fields:[{name:"employeeId"},{name:"user.userName",mapping:"user.userName"}] });

I get an error: user is not defined
the ext wont render it, any solution for that?

friend
25 Apr 2011, 9:02 AM
Modify your store as shown below and see if that helps:



var store = new Ext.data.JsonStore({
autoLoad: true,
url: "/some_data",
root: 'root',
method:'POST',
fields:['employeeId', 'user']
});

fatnjazzy
25 Apr 2011, 9:45 AM
Thanks but I must have the mapping:"user.userName" because I am using sub object in the json

[{employeeId:2,user:{userName:"Admin"}}]