So I have to implement an Array to store my selections between paging, but here comes another problem, so if the user hold CTRL key, I will keep the previous selected items before paging, otherwise, I will not keep that into the array. but , how I can find if the CTRL key is pressed during the selection?
5 Answers, 1 is accepted
When an item is selected, you could check if the Ctrl button was pressed like so:
I hope that this is what you need.
the Telerik team
I capture this at selectionChanging event.
I am capturing it inside the SelectionChanging event and it works as expected (returns True if I hold the Ctrl button). I am testing with the Q3 version of the RadControls.
What is the result if you use the SelectionChanged event?
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thinks get more complicated. But my scenario is simple: keep selected rows for RadGridView with paging using RadDataPager. I want to keep the selected rows after paging:
1. if the user press "ctrl" key, I will keep the selected rows from the previous page
2. otherwise, do not keep the previous selection.
3. after paging again the previous page, the selected item should show selected and I should be able to deselect them.
So, I met a couple of difficulties here by the limit of RadGridView and RadDataPager
1. how to iterate the rows of the gridview to set them into isSelected = true state, it looks like that I can not iterate all of the rows
2. once the paging is happening, it will have selectionchanging event to lost all of the previous selection since RadDataPager does not know anything about the previous page, this is strange design.
Can you have a small example (in code) to illustrate how to implement this scenario? I follow this example
but this is for a grid, and I can iterate through rows, but not gridview
Doing it through the UI / View is a bad pattern and will be more difficult to maintain. The RadGridView recycles rows and you can never be sure the RadGridView has all the rows you are interested in at one time. You will find it loads easier to implement and support if you do it through a ViewModel and allow each item in the collection to indicate whether it is selected or not, as an item becomes "selected" or "unselected" you could add and remove these items from your selected collection.
Paging is evil and a bad UI design pattern...but anyway, if you shared more details I would be happy to throw out some rough examples.