Davemen
Davemen

Reputation: 156

How to expand a MudBlazor table with only 1 row?

When I show the MudBlazor table, it initially looks like this:

enter image description here

In the code, I'm preloading an empty row, so when I click in the bottom area below the line under "Outcome", it expands and looks like this:

enter image description here

How do I programmatically get the table into the state of the second image - showing the blank row?

I've tried using SetSelectedItem with a StateHasChanged(), but that didn't seem to expand that row. Does anyone have any ideas?

Upvotes: 0

Views: 120

Answers (1)

Davemen
Davemen

Reputation: 156

Here's what I did to get it to work:

 protected override void OnAfterRender(bool firstRender)
{
    if (firstRender)
    {
        theRow = tblDesiredOutcome.Items.SingleOrDefault(i => i.Position == Id);
        if (theRow is not null) tblDesiredOutcome.SetSelectedItem(theRow);
        tblDesiredOutcome.SetEditingItem(theRow);
        //SelectedRowClassFunc(item, 1);
        StateHasChanged();
    }
    base.OnAfterRender(firstRender);

Upvotes: 0

Related Questions