@page "/table/export"
@inject IStringLocalizer<NavMenu> NavMenuLocalizer
@inject IStringLocalizer<TablesExport> Localizer
@inject IStringLocalizer<Foo> LocalizerFoo

<h3>@Localizer["TablesExportTitle"] - @NavMenuLocalizer["TableExport"]</h3>
<h4>@((MarkupString)Localizer["TablesExportDescription1"].Value)</h4>

<p>@((MarkupString)@Localizer["TablesExportDescription2"].Value)</p>

<PackageTips Name="BootstrapBlazor.TableExport" />

<p class="mt-3"><b>@Localizer["TablesExportTips"]：</b></p>

<Pre>public void ConfigureServices(IServiceCollection services)
{
    // @Localizer["TablesExportNote1"]
    services.AddBootstrapBlazor();

    // @Localizer["TablesExportNote2"]
    services.AddBootstrapBlazorTableExportService();
}</Pre>

<DemoBlock Title="@Localizer["TablesExportShowExportButtonTitle"]"
           Introduction="@Localizer["TablesExportShowExportButtonIntro"]"
           Name="ShowExportButton">
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true" IsMultipleSelect="true"
           ShowToolbar="true" ShowDefaultButtons="false" ShowExportButton="true"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@Localizer["TablesExportShowExportCsvButtonTitle"]"
           Introduction="@Localizer["TablesExportShowExportCsvButtonIntro"]"
           Name="ShowCsvExportButton">
    <section ignore>
        <p>@Localizer["TablesExportPdfDesc"]</p>
        <PackageTips Name="BootstrapBlazor.Html2Pdf"/>
        <p class="code-label">@((MarkupString)Localizer["TablesExportPdfNote1"].Value)</p>
        <Pre>public void ConfigureServices(IServiceCollection services)
{
    // @Localizer["TablesExportPdfNote2"]
    services.AddBootstrapBlazorHtml2PdfService();
}</Pre>
    </section>
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true" IsMultipleSelect="true"
           ShowToolbar="true" ShowDefaultButtons="false"
           ShowExportButton="true" ShowExportCsvButton="true" ShowExportPdfButton="true"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" />
            <TableColumn @bind-Field="@context.Complete" LookupServiceKey="Foo.Complete" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@Localizer["TablesExportOnExportAsyncTitle"]"
           Introduction="@Localizer["TablesExportOnExportAsyncIntro"]"
           Name="OnExportAsync">
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true" IsMultipleSelect="true"
           ShowToolbar="true" ShowDefaultButtons="false" ShowExportButton="true"
           OnExportAsync="OnExportAsync" OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@Localizer["TablesExportButtonDropdownTemplateTitle"]"
           Introduction="@Localizer["TablesExportButtonDropdownTemplateIntro"]"
           Name="ExportButtonDropdownTemplate">
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true" IsMultipleSelect="true"
           ShowToolbar="true" ShowDefaultButtons="false" ShowExportButton="true"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" />
        </TableColumns>
        <ExportButtonDropdownTemplate Context="ExportContext">
            <div class="dropdown-item" @onclick="() => ExcelExportAsync(ExportContext)">
                <i class="fa-regular fa-file-excel"></i>
                <span>@Localizer["TablesExportButtonExcelText"]</span>
            </div>
            <div class="dropdown-item" @onclick="() => ExcelExportAllAsync(ExportContext)">
                <i class="fa-regular fa-file-excel"></i>
                <span>@Localizer["TablesExportButtonExcelAllText"]</span>
            </div>
            <div class="dropdown-item" @onclick="() => CsvExportAsync(ExportContext)">
                <i class="fa-regular fa-file-excel"></i>
                <span>MS-CSV</span>
            </div>
            <div class="dropdown-item" @onclick="() => ClipBoardExportAsync(ExportContext)">
                <i class="fa-regular fa-file-excel"></i>
                <span>@Localizer["TablesExportButtonCliBoardText"]</span>
            </div>
            <div class="dropdown-item" @onclick="() => ClipBoardExportAllAsync(ExportContext)">
                <i class="fa-regular fa-file-excel"></i>
                <span>@Localizer["TablesExportButtonCliBoardAllText"]</span>
            </div>
        </ExportButtonDropdownTemplate>
    </Table>
</DemoBlock>
