ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: dagarwal82 on September 28, 2016, 06:49:26 am

Title: Is it possible to do just differential update with remote datamodel
Post by: dagarwal82 on September 28, 2016, 06:49:26 am
We are using remote dataModel. Is it possible that getData does a comparison b/w the data it already has and the new data and then do addRow/updateRow/removeRow instead of clearing the grid and redrawing.

It is causing us a problem with detailModel mostly, because when we have a row expanded and grid refreshes it collapses the row.
Title: Re: Is it possible to do just differential update with remote datamodel
Post by: paramvir on September 29, 2016, 09:23:53 am
It could be done by using a unique Id field ( dataModel.recIndx ) to identify rows.

The expanded state of rows is stored as boolean value in rowData.pq_detail.show

1.) In getData() callback, store the expanded state of existing rows (dataModel.data) in an object against unique id of rows.

{ id1: true, id2: false,..... }

and pass on the rowData.pq_detail.show value to corresponding new rows in response.
Title: Re: Is it possible to do just differential update with remote datamodel
Post by: dagarwal on September 29, 2016, 09:48:07 pm
We are not using editing mode. We have dataModel which is set to remote. And we have detailModel which is also set to remote.
Now, when the dataModel for parent does remoteRequest it does a refreshDataAndGrid which causes the expanded row to close down and then reopen again (which in turn causes detailModel to show Loading... message and fetch the data again) even though there are no changes in the data.

Is it clear what I am referring to.
Title: Re: Is it possible to do just differential update with remote datamodel
Post by: dagarwal on September 29, 2016, 10:05:14 pm
Ultimately it calls for _pHierarchy.detachInitView and then $JQPchild.detach() removes the details view and it causes it to reload.
Title: Re: Is it possible to do just differential update with remote datamodel
Post by: paramvir on September 30, 2016, 10:49:58 am
As per your description, you want to refresh data in parent grid without refreshing the detail children.

Solution is similar to my previous post.

The following code ( to be used in getData() callback ) is an example implementation for this example: http://paramquery.com/pro/demos/nesting

Code: [Select]
getData: function ( response ) {
                var data = response.data;
var oldData = this.option('dataModel.data'), recIndx = this.option('dataModel.recIndx'), obj={}, rd;
for(var i=0, len = oldData.length; i<len; i++){
rd = oldData[i];
obj[rd[recIndx]]=rd.pq_detail;
}
for(var i=0, len = data.length; i<len; i++){
rd = data[i];
rd.pq_detail = obj[rd[recIndx]];
}
return { curPage: response.curPage, totalRecords: response.totalRecords, data: data };
            }
Title: Re: Is it possible to do just differential update with remote datamodel
Post by: dagarwal on October 04, 2016, 02:00:20 am
Thanks! It worked !