I am calling LoadLayout on a RadGridView then using a factory class todynamically gets the properties of an object passed in and determines what properties should be shown. Based on what properties should be shown, the factory adds columns if they don't exist from the LoadLayout or gets the column if it does exist and configures it. But if a column was created from the LoadLayout and there is no property associated with it anymore, I need to hide or remove the column.
Based on other forum posts, I've tried:
gridView.MasterTemplate.Columns.Remove(name);
gridView.Columns.Remove(name);
if (gridView.MasterTemplate.Columns.Contains(name)) // returns false
{
var col = gridView.MasterTemplate.Columns[name];
col.VisibleInColumnChooser = false;
col.IsVisible = false;
}
if (gridView.Columns.Contains(name)) // returns false
{
var col = gridView.Columns[name];
col.VisibleInColumnChooser = false;
col.IsVisible = false;
}
If I break after the code above runs, I can see that the column is not longer in the the gridView's column collection, but when its rendered the column is displayed. How do I hide or remove a column immediately after calling LoadLayout?