开发者

Extjs - Multi level json for grid

开发者 https://www.devze.com 2023-02-26 20:46 出处:网络
I have a grid and i need/must (no matter y) to send a multilevel json to it. example: { \"root\" : [ {

I have a grid and i need/must (no matter y) to send a multilevel json to it.

example:

{ "root" : [ { 
        "affiliateId" : 8,
        "name" : "Affiliate Name",
        "email" : "affiliate@gmail.co.il",
        "manager" : { 
            "name"  : "I am the manager",
            "email" : "manager@gmail.co.il"
          },
      } ],
  "totalCount" : 1
}

now, when I build the grid fields I want to use the deeper items, for example:

{
        name:'manager_email',
 开发者_如何学Python       header: "Manager",
        dataIndex: 'manager.email',/******access a deep level******/
        width: 100,
        sortable: true,
        type:'text'
    }

I get no error, just empty cell in the grid.

Thanks


You should look into the mapping config option - define your field like this:

{
    name:'manager_email',
    header: 'Manager',
    mapping:'manager.email'
    ...
}

Another option might be to use a renderer this way:

{
    name:'manager_email',
    header: 'Manager',
    dataIndex: 'manager'
    renderer : function(value,metadata,record){
        return record.data.manager.email;
    }
    ...
}
0

精彩评论

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