fatnjazzy
fatnjazzy

Reputation: 6152

Extjs - Multi level json for grid


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" : "[email protected]",
        "manager" : { 
            "name"  : "I am the manager",
            "email" : "[email protected]"
          },
      } ],
  "totalCount" : 1
}

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

{
        name:'manager_email',
        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

Upvotes: 1

Views: 1215

Answers (1)

Tommi
Tommi

Reputation: 8608

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;
    }
    ...
}

Upvotes: 5

Related Questions