I can able to show grid data when using dataModel option location: "remote".
Now, I want to make data available locally. That means location: "local".
I made changes accordingly, but not able to show grid.
Here is code,
$(function () {
var colM = [
{ title: "", minWidth: 27, width: 27, type: "detail", resizable: false, editable: false },
{ title: "ShipCountry", width: 100, dataIndx: "ShipCountry" },
{ title: "Customer Name", width: 120, dataIndx: "ContactName" }
];
var data = [
{ ShipCountry: "India", ContactName: "Dheeraj"},
{ ShipCountry: "France", ContactName: "Fred"}
];
var dataModel = {
data: data,
location: "local",
sorting: "local",
dataType: "JSON",
recIndx: "ShipCountry",
rPPOptions: [1, 10, 20, 30, 40, 50, 100, 500, 1000]
};
var $gridMain = $("#grid_md").pqGrid({
width: 860, height: 500,
dataModel: dataModel,
editable: false,
colModel: colM,
wrap: false,
hwrap: false,
numberCell: { show: false },
title: "<b>Shipping Orders</b>",
resizable: true,
freezeCols: 1,
freezeRows: 0,
selectionModel: { type: 'cell' },
detailModel: {
cache: true,
collapseIcon: "ui-icon-plus",
expandIcon: "ui-icon-minus",
init: function (ui) {
//var rowData = ui.rowData;
//orderID = rowData["OrderID"];
//make a deep copy of gridDetailModel
var objCopy = $.extend(true, {}, gridDetailModel);
var $grid = $("<div/>").pqGrid(objCopy);
$grid.on("pqgridcellclick", function (event, ui) {
alert("Inside cell click");
});
alert("3A");
$grid.on("pqgridquiteditmode", function (evt, ui) {
//exclude esc and tab
if (evt.keyCode != 27 && evt.keyCode != 9) {
}
});
$grid.on("pqgridcellsave", function (evt, ui) {
alert("Inside cell save");
alert(JSON.stringify(ui));
});
return $grid;
}
}
});
//This is just to show child grid data
var childData = [{Name:"Ram",Addr:"India"}];
//details grid
var gridDetailModel = {
height: 130,
pageModel: { type: "local", rPP: 5, strRpp: "" },
dataModel: {
data:childData,
location: "local",
sorting: "local",
dataType: "JSON",
sortIndx: "Name"
},
colModel: [
{ title: "Name", width: 80, dataIndx: "Name" },
{ title: "Address", width: 80, dataType: "integer", dataIndx: "Addr" }
],
editable: true,
groupModel: {
dataIndx: ["Name"],
dir: ["up"],
title: ["{0} - {1} product(s)"],
icon: [["ui-icon-triangle-1-se", "ui-icon-triangle-1-e"]]
},
freezeCols: 0,
flexHeight: true,
flexWidth: true,
numberCell: { show: false },
title: "Name Details",
showTop: false,
showBottom: false
};
});
I just want to use local data instead of remote.
I have been trying since last 2-3 hours.
Please help me.