var columnsModel = new Array();
columnsModel.push({ header: "ID", property: "id", width: 60, sort: true });
columnsModel.push({ header: "Name", property: "name", width: 200, sort: true });
columnsModel.push({ header: "Birthday", property: "birthday", width: 100, sort: true, align: "center", format: "date" });
columnsModel.push({ header: "E-mail", property: "email", width: 250, sort: true });
columnsModel.push({ header: "Car Name", property: "car.name", width: 100, sort: true, align: "left" });
columnsModel.push({ header: "Car Year", property: "car.year", width: 100, sort: true, align: "right" });
$("#ninjaGridSample").ninjaGrid({
dataSource: source,
columns: columnsModel,
pageSize: 10,
sortColumn: "id",
sortOrder: "desc",
minHeight: 150,
maxHeight: 150,
onRowCreated: function (tr, obj) { //-- set a function to format each row
switch (obj.car.name) {
case "Renault": { tr.css("background", "#fff2ce"); break; }
case "Fiat": { tr.css("background", "#cee1ff"); break; }
case "Volkswagen": { tr.css("background", "#f00"); break; }
case "Chevrolet": { tr.css("background", "#ffcece"); break; }
case "Ford": { tr.css("background", "#d1e24d"); break; }
}
}
});