There is a bug in the bp:GridViewRowSelectColumn
implementation that prevents it from successfully being hidden or removed from a GridView.
I have created a page (linked below) that demonstrates quite a few different attempted methods to show/hide the column.
Please run the example and observe the behavior.
What I would list as additional functional requirements for this column would be:
- The column can be added/removed without changing the order of all other columns. (It is currently changing the order of columns under some circumstances.)
- The column can be removed without consuming space in the grid when not actually present.
- Other columns can be added/removed without causing column reordering or space wasted for non-existent columns.
ShowHideColumn.dothtml (9.6 KB)
ShowHideColumnViewModel.cs (10.3 KB)
From what I can tell, the issue seems to come from the hard-coded width property of “30px” that is being set in the BuildCol(() method. When the column’s visibility is set to false, the width property (even if set to a different value) is causing the column to still take up space on the page.
Looking at the developer tools while the column is “hidden” you can see that the width element.style value is set to “30px” in the <colgroup>
for the selection column. If you uncheck/remove that setting the table adjusts and is then correct. Either removing the width style property or adding display:none
when the column is meant to be hidden seems to fix the issue.
Note that when a bp:GridViewRowSelectColumn
is not included in the grid, showing/hiding columns seems to work correctly.