Author Topic: How to get handle for the child grid ?  (Read 3108 times)

iamgsprabhu

  • Newbie
  • *
  • Posts: 21
    • View Profile
How to get handle for the child grid ?
« on: May 10, 2016, 02:18:11 am »
Hi

How do I get the handle of nested grid ?

for example: I have main grid (M) and multiple child grids (CM) and each child can have multiple grid (CC). How do I get the handle for (CC) ?

________MM
__________CM
____________CC

Thx
Prabhu

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: How to get handle for the child grid ?
« Reply #1 on: May 10, 2016, 09:12:15 am »
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.

For example, you can use this to loop through the detail grids.

Code: [Select]
toolbar: {
items: [
{
type: 'button',
label: 'Loop through children',
listeners: [{
click: function(){
debugger;
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[i],
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.
}
}
}
}]
}
]
},
« Last Edit: May 10, 2016, 10:10:46 am by paramquery »

iamgsprabhu

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: How to get handle for the child grid ?
« Reply #2 on: May 10, 2016, 06:44:48 pm »
Beautiful, it works like a gem.