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

RadGrid : Selection Order

4 Answers 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 18 Sep 2013, 05:04 PM
Hi,

I am facing an issue with the selected items order . When we select multiple rows in the grid  using shift select the order of the selected values is not the same the order they are present in the grid. For example as we select row 1 and shift select row 10, we are expecting selection order as from row 1 to row 10, but what we are getting as row1, row 10, row 2-9. Please suggest me the possible changes to maintain the order.

Thanks,

4 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 24 Sep 2013, 08:21 AM
Hello Rahul,

Generally, the SelectedItems collection of RadGrid returns the items in order of their selection time. I have prepared a sample RadGrid web site to demonstrate how you can sort their indices. Please run the attached application and let me know if it helps you.

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Ankush
Top achievements
Rank 1
answered on 04 Nov 2014, 08:50 PM
MasterTable.get_selectedItems() is returning selected items in order in which they were selected but I want to ignore the selection order and get items selected in order in which they appear in the radgrid.

Please help!

Thanks,
Ankush
0
Eyup
Telerik team
answered on 07 Nov 2014, 02:41 PM
Hello Ankush,

I will forward your requirement to our dev team and let you know about the result when ready.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Eyup
Telerik team
answered on 13 Nov 2014, 02:15 AM
Hello Ankush,

Thank you again for your patience.

You can achieve the requested functionality using the following approach:
function buttonClick() {
    var selectedItems = $find('<%= RadGrid1.ClientID %>').get_selectedItems();
    selectedItems.sort(SortByIndex);
}
function SortByIndex(a, b) {
    var aIndex = a.get_itemIndex();
    var bIndex = b.get_itemIndex();
    return ((aIndex < bIndex) ? -1 : ((aIndex > bIndex) ? 1 : 0));
}

Hope this helps. Please give it a try and let me know if it works for you.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Rahul
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Ankush
Top achievements
Rank 1
Share this question
or