@page "/table/dynamic"
@inject IStringLocalizer<NavMenu> NavMenuLocalizer
@inject IStringLocalizer<TablesDynamic> Localizer
@inject IStringLocalizer<Foo> LocalizerFoo

<h3>@Localizer["TablesDynamicTitle"] - @NavMenuLocalizer["TableDynamic"]</h3>

<h4>@Localizer["TablesDynamicDescription"]</h4>

<DemoBlock Title="@Localizer["TablesDynamicDataTableTitle"]"
           Introduction="@Localizer["TablesDynamicDataTableIntro"]"
           Name="DataTable">
    <Table TItem="DynamicObject" DynamicContext="DataTableDynamicContext" IsFixedHeader="true" Height="300" />
</DemoBlock>

<DemoBlock Title="@Localizer["TablesDynamicEditTitle"]"
           Introduction="@Localizer["TablesDynamicEditIntro"]"
           Name="Edit">
    <section ignore>@((MarkupString)Localizer["TablesDynamicEditDescription"].Value)</section>
    <Table TItem="DynamicObject" DynamicContext="DataTableDynamicContext" ModelEqualityComparer="ModelEqualityComparer"
           IsMultipleSelect="true" IsBordered="true" IsStriped="true" @bind-SelectedRows="SelectedItems"
           ShowToolbar="true" ShowExtendButtons="true" />
    <div class="mt-3">
        @foreach (var item in SelectedItems)
        {
            <div>@item.GetValue(nameof(Foo.Name))</div>
        }
    </div>
</DemoBlock>

<DemoBlock Title="@Localizer["TablesDynamicDynamicColTitle"]"
           Introduction="@Localizer["TablesDynamicDynamicColIntro"]"
           Name="DynamicCol">
    <Table TItem="DynamicObject" DynamicContext="DataTableDynamicContext" ModelEqualityComparer="ModelEqualityComparer"
           IsMultipleSelect="true" IsBordered="true" IsStriped="true"
           ShowToolbar="true" ShowExtendButtons="true">
        <TableToolbarTemplate>
            <TableToolbarButton Color="Color.Info" Icon="fa-fw fa-solid fa-circle-plus" Text="@ButtonAddColumnText" OnClick="OnAddColumn" />
            <TableToolbarButton Color="Color.Secondary" Icon="fa-fw fa-solid fa-circle-minus" Text="@ButtonRemoveColumnText" OnClick="OnRemoveColumn" />
        </TableToolbarTemplate>
    </Table>
</DemoBlock>

<DemoBlock Title="@Localizer["TablesDynamicPageTitle"]"
           Introduction="@Localizer["TablesDynamicPageIntro"]"
           Name="Pagination">
    <Table TItem="DynamicObject" DynamicContext="DataTablePageDynamicContext" />
    <Pagination PageCount="@PageCount" PageIndex="@PageIndex" OnPageLinkClick="@OnPageLinkClick" class="mt-3" />
</DemoBlock>
