var objoffcar = {
----
dataModel: {
dataType: "JSON",
location: "remote",
recIndx: "Id",
getUrl: function () {
var carId = 1;
if ($('#ddlCar').val() != null) {
carId = $('#ddlCar').val();
}
return { url: "../Home/LoadOffCar", data: { carId: carId, Type: 3 } }
},
getData: function (response) {
$gridoffcar.pqGrid("option", "dataModel.data", response.data);
return { data: response.data };
}
}
};
var $gridoffcar = $("#grid_offcar").pqGrid(objoffcar);
var gridoffcar = $gridoffcar.data("paramqueryPqGrid");
In the options object "objoffcar" the selector grid is referenced to set data on dataModel . I get error this selector is not defined in getdata function.
This code is based on sample code on your website. Why are we referring selector before it is defined. I tried setting dataModel after grid is created like shown below. But it is not working. pqgrid.js blows up
var $gridoffcar = $("#grid_offcar").pqGrid(objoffcar);
$("#grid_offcar").pqGrid( { dataModel:{ getUrl: function () {
return { url: "../Home/LoadOffCar", data: { carId: carId, Type: 3 } };
}
},
getData: function (response) {
$gridoffcar.pqGrid("option", "dataModel.data", response.data);
return { data: response.data };
}
});