*I want to select similar records from grid1 and grid2 at the same time record is selected in grid1. *
For example say that if emp_id 1 has dept_id A and B and emp_id 2 has dept_id C,D and E. A user selects dept_id D . On the back automatically, emp_id 2 and dept_id C and E should get selected. If user selects emp_id 1 and 2 then on the back all the five dept_id should get selected.
Adding event handler for grid :
{
xtype : 'grid1',
id:'accsearchgrid',
cls:'accsearchgrid;
listeners : {
select : function( thisobj, record, index, eOpts ){
console.log("selected");
var AccGridDetails = Ext.getCmp('accsearchgrid');//my grid1
var GrpGridDetails = Ext.getCmp('grpsearchgrid');//my grid2
var Accselection = AccGridDetails.getSelectionModel();
var Grpselection = GrpGridDetails.getSelectionModel();
var Accstore = Ext.getStore('AccDetailsStore');//grid1 store
var Grpstore = Ext.getStore('GrpDetailsStore');//grid2 store
items=[];
for(i=0;i < Accstore.getCount();i++)
{
if(Accselection.isSelected(i))
{
items.push({
"prbalgrp" : Accstore.getAt(i).data.prbalgrp //field which is same in both the grids.
});
}
}
var EncodeItems = Ext.encode(items);
for(j=0; j < items.length ;j++)
{
for(i=0;i < Grpstore.getCount();i++)
{
console.log("items[j]pppp-->"+ items[j].prbalgrp);
if(Grpstore.getAt(i).data.prbalgrp == items[j].prbalgrp){
Ext.getCmp('grpsearchgrid').getSelectionModel().select(i); // error for first time afterwards their is no problem but only one single record is seleted
}
}
}
}
}
},
I am able to select only a single record in other grid. But I beginning error I am getting is :Uncaught TypeError: Cannot call method 'getAt' of undefined ext-all-debug.js:59297 Second time,I mean after selecting second record it is working fine. Please help resolve this.