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

[Solved] Sorting a GridView

3 Answers 169 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Navaneeth
Top achievements
Rank 1
Navaneeth asked on 14 Feb 2011, 09:02 PM
Hello,

I have a GridView bound to an ObservableCollection<Item>.  Each item holds a property called "Order" which holds the display order. When the collection is initialized, it is sorted based on the order and bound to the GridView. GridView shows items in sorted order.

I have a "Move Up" and "Move down" button that moves the selected items up or down. The way this is implemented is by incrementing or decrementing order on the selected item, sort the collection and trigger a property change notification for the grid to redraw. This works well until you have a scroll bar. When the grid redraw the items, the focus is moving to the beginning and scroll bar position is lost. For example, on a grid where 70 rows are there and moving 70th row one level up will jump the focus to the first item and scroll bar will also go back to the first position.

I am wondering is there any way to approach this problem?

3 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 15 Feb 2011, 05:56 PM
Hi Navaneeth,

I made a similar implementation of your requirements. Please, refer to the attached project.

Sincerely,
Ivan Ivanov
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Navaneeth
Top achievements
Rank 1
answered on 15 Feb 2011, 06:49 PM
Hello Ivan Ivanov,

Thanks a lot for looking into the issue. But the sample project that you have sent also faces the same problem. Just scrol to the end, select the last item, click on "Up". You can see the scroll bar jumps back to first. This is because you are Rebinding the grid after Up or Down clicked.

Thanks
0
Ivan Ivanov
Telerik team
answered on 18 Feb 2011, 03:56 PM
Hi Navaneeth,

This is a known behavior in older versions of RadGridView. To achieve your desired results, please use our latest binaries

Sincerely,

Ivan Ivanov
the Telerik team


Tags
GridView
Asked by
Navaneeth
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Navaneeth
Top achievements
Rank 1
Share this question
or