Permanent Grouping

Jun 26, 2008 at 7:14 AM

I want to group my items in the list for a certain column and the user should not be able to remove this certain grouping. I tried the following:

// Create 3 columns for Name, City and Country
Column column1 = new Column("column1", "column1", 120, delegate(object item) { return ((Person)item).Name; });
Column column2 = new Column("column2", "column1", 120, delegate(object item) { return ((Person)item).City; });
Column column3 = new Column("column3", "column1", 120, delegate(object item) { return ((Person)item).Country; });

// Make column3 (Country) invisible, so that it is not shown in the list
column3.IsVisible = false;

// Add column3 to GroupedItems, so that the items will be grouped for this column
// Invisible the first (and only) GroupedItems-Item, to avoid removing the column from the grouping section
this.ListControl1.Columns.GroupedItems[0].IsVisible = false;
// Add the remaining columns to the list
// Add the data

The "Country"-column is not visible in the list section and can not be added by "Column Chooser"-window --> fine
The items of my list will be grouped for the "Country"-column --> fine too
The "Country"-column is still visible in the grouping section, so that the user can remove it :-(

How can I solve this? Any ideas?


Jul 2, 2008 at 11:35 PM

There is no *current* out of the box way of doing what you want - however you could override CustomiseGroupingSection and the CanDrag property. You can override CustomiseGroupingSection by creating your own SectionFactory and intercepting the SectionFactory.CreateCustomiseGroupingSection method. There are examples of creating your own SectionFactory in the test example.

Jul 3, 2008 at 11:58 AM
Hi Lee,

thanks a lot for your response. I made something similar for the "normal" columns of the list. I've added a new property "IsHidden" for each column, to define real hidden (not invisible) columns. I stumbled into the following problem. I have a column in my list, that should be completely invisible. This column should not be shown in the "column chooser" window as well. My first attempt was, to set the property "IsVisible" to "false" for this special column and in the column chooser dialog I only show columns that have "IsVisible = true". This works OK for the first moment.
Then I've removed a column from the list by dropping it into void. This column becomes invisible (IsVisible = false) and there was no way to getting the column back (because the column chooser doesn't show it now).
So I made this new property "IsHidden" for the columns that should never shown and in the column chooser window I show all "unhidden" columns.
I think I can do something similar with the grouping section (Set "Column.IsHidden = true" and do something special in the CreateCustomiseGroupingSection method).