14 Answers, 1 is accepted
You can check this demo for more info.
All the best,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Actually, the recommended way is to iterate through the Items collection of the grid. As the virtualization is turned on by default, RadGridView will create only the visible visual elements. That being said, getting all rows will return only those that are in the view port. That is why, you need to work with the Items instead.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
The problem is that the row selection is lost after paging. I want to keep the previous page's row selection. So I have an array to store the previous page's selection and turn them ito isSelected equal to true after the paging, but if I can not iterate the rowElement, how can I set the row to be selected? something like
I have a list<T> savedSelection
I want to do :
foreach (var rowelement in the RadGridView)
{ if (savedSelection.Contains(rowelement))
rowelement.isselected = true;
}
how can I do this?
Items are object, not gridviewRow type, which mean I can not do anything to the Gridview.
GridViewRow is the visual element, while those in the Items collection are the data items from the source of the grid.
The behavior you experience with selection is the expected one since the source of each page is changed on walking back and forth the pages and there is no guarantee that the source of a particular page is exactly the same as it was before when you were on it. What you can try is to save the selected item(s) on each page, handle PageIndexChanging event for example and set again the selected item(s) when you are at the required page.
Another possible approach would be the one illustrated in this forum thread.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Generally, there should be no problem to add a particular item to the SelectedItems collection of the grid (in case SelectionMode is set to 'Multiple" or "Extended'). However, you need to make sure that this item is available.
Could you provide a bit more details on your scenario - do you still use pager and want to display selected items on navigating through the pages ? Do you try the suggested approach from the forum thread mentioned above ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
thanks for the reply.
Yes, I can set the selectedItems, which is not a problem. But even the selectedItems has that row, but that row does not highlight since it is selected. I want all of the seletedItems are highlight as normal after I added them to selectedItems collection.
There are two scenarios for me but they are rooted at one problem:
1. Paging, I want to keep the selectedItem when paging, I can maintain these with my collections and set them during paging, but they are not highlight as selectedItems, in otherwords, users does not know that item is selected since it is not hightlight visually.
2. Sharing with collegues: I created a permlink and shared with people, but again, the selectedItems can be retrieved since I maintain them but they are not highlighted so users have no idea if they are selected, and if they want to continue to work on the selectedItems, there is no way to tell which ones are selected already.
thanks,
Joe
Please take a look at this blog post for a reference. Will the approach illustrated there fit into your scenario ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
If you want to style conditionally RadGridView's cells, the way to go is to use CellStyleSelector. You can check this help article for a reference. Moreover, you can check the CellStyleSelector online demo.
As for your other question - the GridViewCellStyle resource is needed since our demos are using the Implict Themes theming mechanism. Basically, when you are using it, you need to base your custom style on the needed control using the name of the control and the suffix “Style” as a StaticResource. You can find detailed instruction on how you can apply a Style together with implicit themes in this help article.
Regards,
Yoan
Telerik