Reputation: 1595
I have an object which has two members:
num
which is just an integer and article
which is an object that I get through JSON and has a number of members itself. Now I want to use members from article for the name
and pris
fields in a SlickGrid. The example beneath does not seem to work however:
var columns = [
{ id: "antal", name: "Antal", field: "num", width: 10},
{ id: "namn", name: "Artikelnamn", field: "article.name", width: 50},
{ id: "pris", name: "Totalpris", field: "article.price", width: 50}
];
Can anyone assist me in implementing this correctly based on the code provided?
Upvotes: 1
Views: 1048
Reputation: 7786
Use article
as the field, and employ a column formatter. So:
var columns = [
{
id: "antal", name: "Antal", field: "num", width: 10
},
{
id: "namn", name: "Artikelnamn", field: "article", width: 50,
formatter : function(row, cell, value, columnDef, dataContext){
return value.name;
}
},
{
id: "pris", name: "Totalpris", field: "article", width: 50,
formatter : function(row, cell, value, columnDef, dataContext){
return value.price;
}
}
];
Upvotes: 3