ParamQuery grid support forum

General Category => Help for ParamQuery Grid (free version) => Topic started by: shoushouleb on August 23, 2018, 01:12:13 pm

Title: How to get the data of grid and send to server
Post by: shoushouleb on August 23, 2018, 01:12:13 pm
Hello,
I have a nested grid, i need to get the rows in the grid and send to the server. I tried getData() and pData property. but these methods returns the data and some additional info, so when I stringify() there is data that I don't need. in addition to that I am unable to get the children data .

Thanks
Title: Re: How to get the data of grid and send to server
Post by: shoushouleb on August 23, 2018, 02:20:00 pm
The solution is : (Taken from a post in the forum):

/*
Reference to a detail grid is stored in the corresponding rowData i.e., rowData.pq_detail.child holds a reference to the DOM of the child grid.
So to get all the child grids, you need to loop through all rowData of parent grid.
*/
var grid = $gridMain.data('pqGrid'), //instance of master grid.
                  data = grid.option('dataModel.data'); //data of master grid.
               for(var i=0;i<data.length;i++){
                  var rd = data,
                     dt = rd.pq_detail,
                     child;
                  if(dt && dt.child){
                     //dt.child is reference to the DOM node of the child grid.
                     child = $(dt.child).data('pqGrid');//reference to instance of child grid.
                     var dataChild = child.option('dataModel.data');//data of child grid.
                  }
               }