I've not seen anything in the XamWebGrid documention. I'm thinking here like the WinGrid where if a user drags a column into the display area the cursor changes to a cross when, if the column is dropped, it is removed from the display.
Equally when using the WinGrid there's a standard mechanism which shows a list of the columns in a grid in which those already displayed in the grid are checked. Checking a column adds it to the display.
If the functionality is not there yet do you think it'd feasible to for us to develop something similar to that in WinGrid? Event reporting column movement seem to be available as are calls to add/remove columns and report the list of columns in a band.
Hi,
We don't currently have this feature, but it is on our ToDo list.
For now though, a colleague of mine, Devin Rader, wrote a blog post on doing just that:
http://community.infragistics.com/blogs/devin_rader/archive/2010/01/19/simple-column-chooser-for-xamwebgrid.aspx
Hope this helps,
-SteveZ
I'm currently doing this to get a column chooser from a context menu which works great, but how could I show the column chooser that you guys show when you click the hidden column/column chooser in the headercell. I believe it is XamGridColumnChooserCommandSource in the HeaderCellControl template... I am most interested in getting the re-order from the drag drop without having to implement that myself ;-)
void XamContextMenu_Opening(object sender, Infragistics.Controls.Menus.OpeningEventArgs e) {
if (e.GetClickedElements<HeaderCellControl>().Count > 0) { BuildColumnSelectionContextMenu((XamContextMenu)sender, _endPoints); }
}
void BuildColumnSelectionContextMenu(XamContextMenu contextMenu, XamGrid dataGrid) { if (contextMenu != null && dataGrid != null) { contextMenu.Items.Clear(); contextMenu.Items.Add(Assets.ResourceFiles.Resources.ChooseColumns); contextMenu.Items.Add(new XamMenuSeparator()); foreach (Column column in dataGrid.Columns.OfType<Column>()) { Binding binding = new Binding("Visibility"); binding.Converter = new Assets.Converters.VisibilityToBoolConverter(); binding.Mode = BindingMode.TwoWay; CheckBox cb = new CheckBox(); cb.Content = GetColumnHeaderString(column); cb.SetBinding(CheckBox.IsCheckedProperty, binding); cb.DataContext = column; contextMenu.Items.Add(cb); } } } -Mark
void BuildColumnSelectionContextMenu(XamContextMenu contextMenu, XamGrid dataGrid) { if (contextMenu != null && dataGrid != null) { contextMenu.Items.Clear(); contextMenu.Items.Add(Assets.ResourceFiles.Resources.ChooseColumns); contextMenu.Items.Add(new XamMenuSeparator()); foreach (Column column in dataGrid.Columns.OfType<Column>()) { Binding binding = new Binding("Visibility"); binding.Converter = new Assets.Converters.VisibilityToBoolConverter(); binding.Mode = BindingMode.TwoWay; CheckBox cb = new CheckBox(); cb.Content = GetColumnHeaderString(column); cb.SetBinding(CheckBox.IsCheckedProperty, binding); cb.DataContext = column; contextMenu.Items.Add(cb); } } }
-Mark
Hi Mark,
The XamGrid has a ShowColumnChooser method, that you can invoke to show the Dialog:
http://help.infragistics.com/NetAdvantage/Silverlight/2010.2/CLR4.0/?page=xamGrid_Column_Chooser.html
Thanks Steve, that's exactly what I was looking for.