ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started 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.
-
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.
-
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.
-
Ultimately it calls for _pHierarchy.detachInitView and then $JQPchild.detach() removes the details view and it causes it to reload.
-
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
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 };
}
-
Thanks! It worked !