XamDataGrid ColumnChooser Implementation

John Doe / Saturday, July 11, 2009

This is a frequently asked scenario with the XamDataGrid. This is why I will be showing one way of how to enable a Column Chooser for your XamDataGrid.

I have created a class ColumnChooserManager, which will create a small column chooser control and display it when you right click on the Field's Label. The ColumnChooser control is bound to a partucular XamDataGrid's FieldLayouts collection. It works with flat as well as hierarchical data structure, so that you can choose to show / hide fields from different layouts. Because of the fact that the FieldLayouts are generated when they are expanded, you will be able to see a particular field layout only when it is expanded.

Enabling the column chooser is very easy - just target the XamDataGrid -

MyUtilities.ColumnChooser.ColumnChooserManager.EnableColumnChooser(xamDataGrid1);

As you can see on the screenshot, the NestedData field is in the nested layout. When you expand any record, you will be able to select that nested layout throught the ComboBox of the ColumnChooser control.

The visual design looks choppy because I have almost no sense of look and feel, and I will leave that to you.

I will post the MyUtilities.dll project file in another blog post and will update it regularly with the new added contents.

XamDataGrid_ColumnChooser.zip