Author Topic: Is it possible to do just differential update with remote datamodel  (Read 2826 times)

dagarwal82

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 2
    • View Profile
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.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6313
    • View Profile
Re: Is it possible to do just differential update with remote datamodel
« Reply #1 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.

dagarwal

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Is it possible to do just differential update with remote datamodel
« Reply #2 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.

dagarwal

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Is it possible to do just differential update with remote datamodel
« Reply #3 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.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6313
    • View Profile
Re: Is it possible to do just differential update with remote datamodel
« Reply #4 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 };
            }
« Last Edit: September 30, 2016, 10:54:28 am by paramquery »

dagarwal

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Is it possible to do just differential update with remote datamodel
« Reply #5 on: October 04, 2016, 02:00:20 am »
Thanks! It worked !