PDA

View Full Version : how to get the selected row data of dynamic gridpanel in c# ?



Kasani007
Sep 15, 2015, 10:20 AM
how to get the selected row data of dynamic gridpanel in c# ?

nasim
Oct 16, 2015, 11:26 AM
after you created your grid on server side, depend on what you want to do with the selection and when you want to use it you can write handler on the considered event by EXT js command so that you can access to the selected row's data on the time that event fired. for instance if you want to do something with the selected row value in CellClick event you can write:

(Let's assume your grid's name: Grid1, and required field's name: MyData)
Grid1.Listeners.CellClick.Handler="alert(App.Grid1.getSelectionModel().selected.items[0].data.MyData);";

on aforementioned sample you would see the required field's data of the first selected row on every time that has been clicked on a cell of the grid; however, to have an access to more than one selected row you can use loop functions of EXT js, I provided a sample on following it might be useful for you:


for(var i=0; i < App.Grid1.store.getCount(); i++)
{
if(App.Grid1.getSelectionModel().isSelected(i))
{
alert(App.Grid1.getSelectionModel().selected.items[i].data.MyData);
}
}