ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: mshapiro on January 29, 2015, 04:34:26 am
-
I have "track: true" as a grid option and I am populating the grid with JSON data. If I include dataModel as part of the grid object definition then everything works as expected and I can use rollback to undo edits. If I populate the data using $grid.pqGrid("option", "dataModel.data", response.data) after the grid is created , then edits do not make the grid dirty and rollback has no effect. I've tried various combinations of commit and refresh with no success. How can I use isDirty and rollback if I load dataModel.data after the grid is created? Thank you.
-
IsDirty/ Rollback is not dependent upon how you load data into the grid.
If you populate the data using $grid.pqGrid("option", "dataModel.data", response.data) after the grid is created, you have to set
1) dataModel.location = "local" initially.
and
call refreshDataAndView when you set data.
$.ajax({
url: "/pro/products/get",
dataType: 'json',
success: function (response) {
debugger;
$grid.pqGrid("option", "dataModel.data", response.data)
.pqGrid("refreshDataAndView");
}
});
Please use trackModel: { on: true }, //to turn on the track changes instead of track: true
-
It's working now. I discovered that not only is setting dataModel.location = "local" initially a requirement, dataModel.recIndx also has to be set initially. Thank you.