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

Selected Rows Order

1 Answer 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
lampy
Top achievements
Rank 1
lampy asked on 21 May 2008, 08:55 PM
Hello,

I have an app where I move rows between grids.  I have run into an issue because it seems like the order of grid.SelectedItems is random and not in the order of how the user clicked them  Is there a way to get grid.SelectedItems in the order of how the user clicked them?  Right now the only option is to roll my own functionality by using the row selected client event to capture the order and store it in a hidden field that I access server side to add the other grid.  I rather not do this if there is a solution or a better way accomplish this.  Any idea?

Thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Veli
Telerik team
answered on 27 May 2008, 05:41 AM
Hello lampy,

The RadGrid.SelectedItems collection stores the indexes of the selected items in the order they are selected. To demonstrate, please follow these steps:

1. Set  EnablePostBackOnRowClick="true" in the ClientSettings of RadGrid
2. Subscribe to the ItemCommand event
3. Place the following code in the ItemCommand event handler:

if (e.CommandName == "RowClick"
    for(int i=0; i<RadGrid1.SelectedItems.Count; i++) 
    Response.Write(RadGrid1.SelectedItems[i].RowIndex.ToString()); 

When you click on a row and the page makes a postback, you will see the indexes of the selected items enumerated in the order they are selected.

Regards,
Veli
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
lampy
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or