Closed Genmutant closed 1 month ago
I successfully reproduced the issue reported (BlazorAppTest/HxGrid_Issue705_Test).
It is a bug (possibly caused by the design of HxGrid
where the columns are rendered first to allow their usage as templates for the grid rows).
For now, as a simple workaround you can use this code to achieve the effect you expect:
<HxGrid TItem="RowEntry" DataProvider="GetGridData">
<Columns>
@if (ShowAllColumns)
{
<HxGridColumn Order="1" HeaderText="FirstColumn" ItemTextSelector="entry => entry.FirstColumn"/>
}
<HxGridColumn Order="2" HeaderText="SecondColumn" ItemTextSelector="entry => entry.SecondColumn" />
@if (ShowAllColumns)
{
<HxGridColumn Order="3" HeaderText="ThirdColumn" ItemTextSelector="entry => entry.ThirdColumn" />
}
</Columns>
</HxGrid>
Please note the Order
parameter, which ensures the right order of the columns if rendered conditionally.
cc @jirikanda
(TBD: Consider marking the Visible
parameter obsolete. Still the issue should be resolved as it obviously not only affect the Visible
, but also other parameters of the HxGridColumn
.)
I'm trying to optionally Hide some HxGridColumns, with the Visibility bound to a HxSwitch. The problem I have is that the first time the Checked-State is changed, the column visibility is not changed. Any Checked-Change afterwards triggers a visibilty change, but it is out of sync with the bound value.
I'm using a current dotnet 8 Blazor with InteractiveServer Rendering. Here is my example, which doesn't work:
It seems that the
IsVisible
state change is only reflected after the column-visibility check is already done inGetColumnsToRender
.