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

Binding To SelectedItem and Paging

1 Answer 57 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Michael Rogers
Top achievements
Rank 2
Michael Rogers asked on 18 Mar 2011, 02:57 PM
I have a project where the Grid's selected item is bound to a Dataform.  When a user clicks on an item in the grid the dataform is displayed along with related data in other grids.  Those grids are then bound to that dataform's currentitem.  Ideally we want the user to be able to return to the top level and be able to page without the binding changing.  We want the binding to update only when the user selects a new grid item.  With paging enabled each time a page is changed the first item in the grid is selected causing all the data in the lower levels to be cleared.   I was wondering if you had any suggestions on how to handle this situation.

Thanks
Michael

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 21 Mar 2011, 11:29 AM
Hi Michael Rogers,

This behaviour is by design. Let me try to explain how paging works.

When there is paging involved, RadGridView is in fact unaware that it is being paged. Let's say that we have a page size of 10. When on the first page, RadGridView simply "thinks" that someone has assigned it an ItemsSource with 10 items. It is not aware of the fact that these 10 items are in fact part of a larger data set.

When the user moves to another page, RadGridView simply "thinks" that someone is changing its ItemsSource to something else. Which is the new page. In other words, RadGridView is unaware of this larger paging logic, it does not know how many pages are there and so on. 

From its point of view -- someone is simply changing its ItemsSource to something new and that is all. 

Now, when the ItemsSource is changed -- previous selection is lost. That is why you can't be on page 2 and have an item selected on page 1. That is because there simply is not page 1 from RadGridView's perspective.

I hope this makes sense.

All the best,
Ross
the Telerik team
Tags
GridView
Asked by
Michael Rogers
Top achievements
Rank 2
Answers by
Rossen Hristov
Telerik team
Share this question
or