PART III [example: Column Groups A.K.A. Merged Column Headers]
Recently we have had a lots of requests for a feature referred as column groups / merged column headers / common headers for two or more columns - something like :
Here we have three ordinary columns ( L, W, H) with regular column headers . There is also an additional common header – ‘Dimensions’ which spans over the three regular headers.
Unfortunately RadGridView for Silverlight and WPF does not support this internally (yet).
The good news is that RadGridView is a flexible and easily extendable control so we can easily attach a new column grouping behavior. You can see it in action here:
(live & clickable example)
We set up the common headers codeless with a few lines of XAML:
As you can see, when adding a common header we need to set three properties:
StartColumnIndex – defines the first column of the column group
ColumnSpan – tells the header how many columns to unite
Caption – defines the text content of the common header.
*We are not limited to text content here. Since the common header is an ordinary user control with its own XAML you can customize it to add any UI elements , images etc.
* This approach has some limitations e.g. column freezing, column reordering are explicitly disabled by the behavior. We are working on providing this as an internal feature to RadGridView for our future versions when these limitations will be solved.
For your copy/paste needs you can download a
To have this working in your own project you will have to grab the following :
ColumnGroupsBehavior.cs - the attached behavior itself.
CommonHeader.xaml/.cs - the common header user control. You can modify the XAML within to provide more complex content.
SecondaryHeader.xaml/.cs –this is the placeholder for the common headers ( the secondary header row rendered above the ordinary RadGridView header row) . It provides the scrolling & resizing of the common headers.
Additionally you will need a reference to the System.Windows.Interactivity.dll
Subscribe to be the first to get our expert-written articles and tutorials for developers!
All fields are required