BlazorTable
BlazorTable copied to clipboard
How do you hide column ?
Blazor beginner, How do you hide a column ?
Columns can't be hidden. I will look to add this in a future release.
Add Class="d-none" to the column if you are using Bootstrap - that seems to work.
I want to show and hide dynamically
I tested setting a checkbox on a page to control visibility, then setting the Class based on this using a variable, e.g.
string columnCSS => columnVisible ? null : "d-none";
bool columnVisible = true;
and in the table
<Column TableItem="PersonData" Title="Full Name" Field="@(x => x.full_name)" Sortable="true" Filterable="true" Width="20%" Class="@columnCSS" />
However this was rather flaky - the checkbox caused it to appear and disappear in the reverse of the expected value! Not sure what's going on.
I also have this use case. Based on the role of the user I need to show only a select set of columns.
Currently, I have whole <Column></Column> sections selectively wrapped inside @if statements - this works well to initially render the table correctly. Toggling, however, causes Columns to be added repeatedly. I'll opt to redraw the whole table instead.
Using bootstrap/css/html to simply toggle visibility of columns is not enough, since both actions and data would still be exposed.
Cheers, Gregor