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

Is it possible to sort on GridViewSelectColumn?

4 Answers 175 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Bob asked on 16 Jun 2011, 07:48 PM

I would like to sort my RadGridView on the GridViewSelectColumn, moving the selected rows to the top if possible.  Do you have any demos to show how this is done?

4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 17 Jun 2011, 07:07 AM
Hello Bob,

Basically, each CheckBox in the GridViewSelectColumn is bound to the IsSelected property of the corresponding row. If you want to be able to sort it, you may create your own custom column as illustrated in this forum thread.
 

All the best,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 20 Jun 2011, 09:33 PM
Thank you for that example.  I decided to implement a different approach and add a RadMenu to the user control that contains the grid.  On the menu I put items to Show Selected, Show Unselected, and Clear All Filters.  This was working perfectly until I came upon a problem with an indexer out of range in the GridView.IndexTree when a refresh occurs.  I will try to explain the details as best as I can here.  The project is extremely large, and right now I don't have a smaller example I can upload.

Some Background on the Project:
The RadGridView and RadDataPager I am using is contained within a UserControl class.  The ItemsSource of the grid and pager is bound to a local property of the UserControl, and this property is of type QueryableCollectionView with the SourceCollection as type RadObservableCollection.  The CollectionChanged event is loading paged data by calling various delegates within different view models in the project.  This allows us to keep the user control generic to the type of view it will support as the delegates will handle the specific type of entity data that is required.  I pass the sort, filter, and group descriptors to the delegates so that the entity framework can handle the filtering of returned records.  This architecture is working flawlessly, and I don't have any issues with the functionality to load, display, and page data on the grid in this design. 

The Problem:
The problem I started having is when I tried to capture and filter by the selected rows, but I only have an issue when the grid goes from an empty state (no records in the collection after a selection filter) to a non-empty state.  For example, when there are no selected rows in the grid, and my menu selection of "Show Selected" is clicked, the SourceCollection of the QueryableCollectionView is cleared as there is nothing to get.  The grid displays empty data correctly, but when data is loaded again (SourceCollection results are added on a refresh of all data), I receive an exception that "Index was outside the bounds of the array".

The call stack at this point looks like this:
Telerik.Windows.Controls.GridView.dll!Telerik.Windows.Controls.GridView.IndexTree.Set(int index, double value) Line 387 + 0x39 bytes    C#<br>    
  Telerik.Windows.Controls.GridView.dll!Telerik.Windows.Controls.GridView.IndexTree.
this[int].set(int index, double value) Line 119    C#<br>> 
  Telerik.Windows.Controls.GridView.dll!Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.MeasureOverride(System.Windows.Size constraint) Line 1294    C#<br>
    [External Code]
    
 If I do a quick watch on the IndexTree at the time of the exception, I can see that the Capacity is set to 8, the actual element tree has 16 entries (0 to 15), but the index is trying to set tree element 16.  Since none of my code is accessible on the call stack at this point, I don't see anything I am doing to create this exception.  The last method of my code that was executed was a Refresh against the SourceCollection.

I appreciate any help you can provide in resolving this exception.  If you really need a sample project, I will try to put something smaller together that replicates the issue, but it will take some time.
0
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 21 Jun 2011, 05:50 PM
Update:  We resolved this exception.  The SourceCollection count was not being zeroed correctly.   Thanks again for your help.
0
Maya
Telerik team
answered on 21 Jun 2011, 06:16 PM
Hi Bob,

I am really glad you found the most appropriate for your settings solution. Please let me know if you need any further assistance.
 

Best wishes,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Answers by
Maya
Telerik team
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Share this question
or