ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: mshapiro on January 29, 2015, 04:34:26 am

Title: IsDirty/rollback when using "option", "dataModel.data" to load the grid
Post 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.
Title: Re: IsDirty/rollback when using "option", "dataModel.data" to load the grid
Post by: paramvir on January 29, 2015, 09:51:02 pm
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.

Code: [Select]
     $.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
Title: Re: IsDirty/rollback when using "option", "dataModel.data" to load the grid
Post by: mshapiro on January 30, 2015, 03:08:42 am
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.