'MudTable Default SelectedItem
I am trying to setup a table from MudBlazor (MudTable) with single row select but I can't seem to find a way on how I could set the default item value. The code I have is fairly similar to this example in their website. Except on how I load the data, I am using ServerData property instead of Items.
Tried adding something like on "OnAfterRender", "OnInitialized", etc... but no luck.
protected override OnAfterRender(bool firstRender)
{
table.SelectedItem = MyDesiredDefaultValue;
//or
table.SetSelectedItem(MyDesiredDefaultValue);
}
Solution 1:[1]
Add a StateHasChanged call to your code.
Example
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
table.SelectedItem = MyDesiredDefaultValue;
StateHasChanged();
}
}
Demo
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Quickz |
