This is a migrated thread and some comments may be shown as answers.

Grid selected index

1 Answer 313 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff Tang
Top achievements
Rank 1
Jeff Tang asked on 04 Nov 2008, 08:12 AM
how to get the total number of selected rows of a grid in javascript funtion?
how to get the selected rows index of grid in javascript function?

I have a button, and I want to get the above two information when I click the button in client side. Can I do this? Thanks.

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 04 Nov 2008, 08:57 AM
Hello Jeff,

1. Selected data items count:
var radgrid = $find('<%= RadGrid1.ClientID %>');  
var selectedItems = radgrid.get_masterTableView().get_selectedItems().length;  
 

2. Get the index of the selected data item
var radgrid = $find('<%= RadGrid1.ClientID %>');  
radgrid.get_masterTableView().get_dataItems();  
var selectedItem = radgrid.get_masterTableView().get_selectedItems()[0];  
var index = selectedItem._itemIndexHierarchical;  

3. Get table row (real) index
var radgrid = $find('<%= RadGrid1.ClientID %>');  
var realindex = grid.get_masterTableView().get_selectedItems()[0].get_element().rowIndex; 

I hope this helps.

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Jeff Tang
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or