Friday, June 5, 2015

A GridViewDataColumn decorated with GroupIndex="0" at a DevExpress ASPxGridView cannot just be hidden by setting its visibility to false.

This won't fly:

MyGrid.Columns[0].Visible = false;

 
 

The fix is to remove the GroupIndex setting from the markup and manage it a the C# side. You will notice that .GroupIndex does not hang off of MyGrid.Columns[0] the way .Visible does so you will also have to do some casting to get the specific type of column in question like so:

GridViewDataColumn subset = (GridViewDataColumn)MyGrid.Columns[0];
if (_isToShowMoreThanOneSubsetOfSuperset)
{
   subset.GroupIndex = 0;
   subset.Visible = true;
}
else
{
   subset.GroupIndex = -1;
   subset.Visible = false;
}

No comments:

Post a Comment