@page "/complex-test"
@using BlazorApp2.Components.Components
@using Entity

<h3>ComplexTest Demo2</h3>

<div style="font-size:18px;">
    在本例中，编辑弹窗EditTest组件里面模拟从后台通过ID取数，UI界面上有显示，点保存时，实际对象相应属性仍为null
    <br />
    测试复现过程：
    <br />
    1、点编辑，然后点保存
</div>

<Table TItem="TestFoo" Items="TestList" ShowToolbar="true" ShowExtendButtons="true" IsBordered="true" EditDialogSize="Size.Medium"
   TableSize="TableSize.Compact" IsStriped="true" OnSaveAsync="OnSaveAsync">
    <TableColumns>
        <TableColumn @bind-Field="context.Id" Text="ID"></TableColumn>
    </TableColumns>
    <EditTemplate>
        <EditTest Model="@context"></EditTest>
    </EditTemplate>
    <EditFooterTemplate>
        <DialogCloseButton />
        <DialogSaveButton Color="Color.Primary" Icon="fa-solid fa-floppy-disk" Text="保存" />
    </EditFooterTemplate>
</Table>


@code {

    private List<TestFoo> TestList { get; set; } = new List<TestFoo>
    {
        new TestFoo { Id = 3 }
    };

    private async Task<bool> OnSaveAsync(TestFoo foo, ItemChangedType type)
    {
        // 模拟保存数据的异步操作


        return true;
    }
}
