开发者

Extjs combobox - getting json deeper values

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.Js开发者_StackOverflow社区onStore({
    autoLoad: true,
    url: "/some_data",
    root: 'root',   
    methos:'POST',
    fields:[{name:"employeeId"},{name:"user.userName"}] });

the ext wont render it, any solution for that?


Use the 'mapping' property on fields in your store to remap the "deep" values to simple names the ComboBox can then reference:

new Ext.form.ComboBox({
    fieldLabel: 'Manager',
    hiddenName: 'employeeId',
    store: new Ext.data.JsonStore({
        root: 'root',
        url: '/some_data',
        method: 'POST',
        fields: [
            {name: 'employeeId'},
            {name: 'userName', mapping: 'user.userName'}
        ]
    }),
    displayField: 'userName',
    valueField: 'employeeId'
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜