I have a form with a series of checkboxes that need to be disabled based on the state of the other checkboxes (and some other flags). They aren't triggering the disabled state, though. I've tried replacing bind-Checked with direct calls to Checked and CheckedChanged and manually set the disabled state, but that isn't working either. I can see that the Disabled property is being set to true, but the control is still active. I've also tried explicitly calling StateHasChanged and not calling it, neither work. Is there something I'm missing, or is this a bug in Blazor?
This is essentially the setup I'm using:
<div class="form-group">
<SfCheckBox @bind-Checked="@FirstOption"
Disabled="SecondOption || ThirdOption"
/>
</div>
<div class="form-group">
<SfCheckBox @bind-Checked="@SecondOption"
Disabled="FirstOption || ThirdOption" />
</div>
<div class="form-group">
<SfCheckBox @bind-Checked="@ThirdOption"
Disabled="FirstOption || SecondOption" />
</div>
@using Syncfusion.Blazor.Buttons
<div class="form-group">
<SfCheckBox Label="Option 1" @bind-Checked="@FirstOption"
Disabled="SecondOption || ThirdOption" />
</div>
<div class="form-group">
<SfCheckBox Label="Option 2" @bind-Checked="@SecondOption"
Disabled="FirstOption || ThirdOption" />
</div>
<div class="form-group">
<SfCheckBox Label="Option 3" @bind-Checked="@ThirdOption"
Disabled="FirstOption || SecondOption" />
</div>
@code{
public bool FirstOption = false;
public bool SecondOption = false;
public bool ThirdOption = false;
}
|
Alright, I tested and found it doesn't happen with regular checkboxes, but it DOES happen consistently with checkboxes in an SfGrid component's edit dialog. I've attached a sample showing the issue.
Attachment: CheckboxDisabledIssue_fa6f747c.7z
<SfGrid @ref="MyGrid"
DataSource="MyOptList ?? new List<Options>()"
TValue="Options"
Toolbar="@(new List<string>() { "Add", "Edit", "Delete" })">
<GridEvents TValue="Options" OnActionComplete="ActionComplete"></GridEvents>
..
@code{
public void ActionComplete(ActionEventArgs<Options> args)
{
if (args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.Add) || args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.BeginEdit))
{
MyGrid.PreventRender(false);
}
}
} |
That has fixed my issue.
Is there any documentation about when this is turned on by default? The documentation you linked implies that you need to explicitly call PreventRender on components, but we haven't done that here and it's lead to a few problems where we don't know why things aren't rendering.