Grouping by GridViewImageColumn
Date Posted | Product | Author |
---|---|---|
May 09, 2014 | RadGridView | Desislava Yordanova |
How To
By default, RadGridView does not support grouping by GridViewImageColumn functionality. This article demonstrates how to implement such a behavior.
Solution
1. First, let’s populate the RadGridView with data. For this purpose, we will start with creating a sample class MyObject, which have Photo property of type Image.
The custom business object:
You will notice that you are not allowed to drag the GridViewImageColumn’s header and drop it over the “Drag a column here to group by this column” area.
2. In order to enable drag and drop functionality for the GridViewImageColumn’s header over the GroupPanelElement, it is necessary to use the RadDragDropService. Subscribe for its PreviewDragStart event to start the RadDragDropService if you are dragging a GridHeaderCellElement. Use the PreviewDragOver event to allow dropping over the GroupPanelElement:
3. Use the GroupByChanged event to display the GroupFieldElement.RemoveButton
4. Now, we need to implement the logic for grouping the rows. We will use the custom grouping functionality of the RadGridView. Set the EnableCustomGrouping property to true and subscribe to the CustomGrouping event, where we will group rows by image name:
5. The last thing we need to do is to subscribe to the GroupSummaryEvaluate event and construct the desired string for the group’s title:
A complete solution in C# and VB.NET can be found here.