ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: svk123 on December 22, 2015, 12:54:34 pm
-
Hello,
I trying to use Header filtering. If I bring the data using spaghetti code and insert it into pqgrid at time of grid declaration, the filter works fine. However, if I bring the data using an Ajax call and insert it into the datamodel later, the filter is not working. In this case data is set as []; at time of grid declaration. Am I missing any refresh for the filter? I am using 2.0.4 version.
Please find below my code of the ajax call:
$.ajax({
type: "POST",
url: "F1910.aspx/bindGrid1",
data: '{"apprlvl":"' + appr + '"}',
processData: false,
contentType: "application/json",
dataType: "json",
async: true,
cache: false,
success: function (msg) {
var obj = eval(msg.d);
$("#grid_json").pqGrid("option", "dataModel", { data: obj, sorting: "local",sortIndx: ["uckalerts","pono", "posrno"], sortDir: ["down","up","up"]});
$("#grid_json").pqGrid("refreshDataAndView");
},
error: function (x, e) {
alert("The call to the server side failed. " + x.responseText);
}
});
Thanks,
SVK
-
$("#grid_json").pqGrid("option", "dataModel", { ....}); overrides all the properties ( including default ones ) of dataModel which is problematic if you skip any dataModel property.
As an alternative please declare the static properties like dataModel.sorting = "local" during grid initialization and try to update the dataModel properties individually in the success callback
e.g.,
$("#grid_json").pqGrid("option", "dataModel.data", data );
$("#grid_json").pqGrid("option", "dataModel.sortIndx", .... );
and so on.