feat: Blazor 模式下增加固定表头属性
This commit is contained in:
parent
e2cb79b4ec
commit
acdf57a0f8
|
@ -78,6 +78,12 @@ namespace Bootstrap.Admin.Components
|
|||
[Parameter]
|
||||
public RenderFragment<TItem>? EditTemplate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 是否固定表头 默认为 false 不固定表头
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public bool FixedHeader { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 Table 实例
|
||||
/// </summary>
|
||||
|
|
|
@ -60,6 +60,24 @@ namespace Bootstrap.Admin.Components
|
|||
[Parameter]
|
||||
public RenderFragment? TableFooter { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 是否固定表头 默认为 false 不固定表头
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public bool FixedHeader { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 是否自适应高度 默认为 false 不自适应高度
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public bool AutoHeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 是否显示搜索框 默认为 false 不显示搜索框
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public bool ShowSearch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 数据集合
|
||||
/// </summary>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@inherits DictsBase
|
||||
|
||||
<EditPage Id="dict" TItem="Bootstrap.Security.BootstrapDict" SubmitModalTitle="字典编辑窗口" QueryModel="QueryModel" OnQuery="Query" OnAdd="Add" OnDelete="Delete" OnSave="Save">
|
||||
<EditPage Id="dict" FixedHeader="@FixedHeader" TItem="Bootstrap.Security.BootstrapDict" SubmitModalTitle="字典编辑窗口" QueryModel="QueryModel" OnQuery="Query" OnAdd="Add" OnDelete="Delete" OnSave="Save">
|
||||
<QueryBody>
|
||||
<LgbInputText ColumnClass="col-sm-auto" @bind-Value="@context.Category" maxlength="50" />
|
||||
<Select ColumnClass="col-sm-auto" Items="QueryDefine" TItem="int" @bind-Value="@context.Define" />
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using Bootstrap.Admin.Components;
|
||||
using Bootstrap.DataAccess;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Bootstrap.Pages.Admin.Components
|
||||
{
|
||||
|
@ -8,6 +10,12 @@ namespace Bootstrap.Pages.Admin.Components
|
|||
/// </summary>
|
||||
public abstract class QueryPageBase<TItem> : PageBase where TItem : class, new()
|
||||
{
|
||||
/// <summary>
|
||||
/// 获得/设置 是否固定表头 默认为 false 不固定表头
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public bool FixedHeader { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 TItem 实例
|
||||
/// </summary>
|
||||
|
@ -20,6 +28,14 @@ namespace Bootstrap.Pages.Admin.Components
|
|||
/// <param name="pageItems">每页显示数据条目数量</param>
|
||||
protected abstract QueryData<TItem> Query(int pageIndex, int pageItems);
|
||||
|
||||
/// <summary>
|
||||
/// OnParametersSet 方法
|
||||
/// </summary>
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
FixedHeader = DictHelper.RetrieveFixedTableHeader();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新建方法
|
||||
/// </summary>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
查询结果
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<Table @ref="Table" Id="@Id" TItem="TItem" SubmitModalTitle="@SubmitModalTitle" OnQuery="QueryData" OnAdd="OnAdd" OnDelete="OnDelete" OnSave="OnSave">
|
||||
<Table @ref="Table" Id="@Id" FixedHeader="@FixedHeader" TItem="TItem" SubmitModalTitle="@SubmitModalTitle" OnQuery="QueryData" OnAdd="OnAdd" OnDelete="OnDelete" OnSave="OnSave">
|
||||
<TableToolbarTemplate>
|
||||
@TableToolbarTemplate
|
||||
</TableToolbarTemplate>
|
||||
|
|
|
@ -13,7 +13,31 @@
|
|||
</div>
|
||||
|
||||
<div class="table-wrapper">
|
||||
<table class="table table-striped table-bordered table-hover table-selected" id="@($"{Id}_table")">
|
||||
@if(FixedHeader)
|
||||
{
|
||||
<div class="fixed-table-header">
|
||||
<table class="table table-bordered table-hover table-selected">
|
||||
<thead>
|
||||
<tr>
|
||||
@if (ShowCheckbox)
|
||||
{
|
||||
<th class="table-col-checkbox"><Checkbox TItem="TItem" SetCheckCallback="CheckState" ToggleCallback="ToggleCheck"></Checkbox></th>
|
||||
}
|
||||
@if (ShowLineNo)
|
||||
{
|
||||
<th class="table-col-lineno">行号</th>
|
||||
}
|
||||
@TableHeader?.Invoke(EditModel)
|
||||
@if (ShowButtons)
|
||||
{
|
||||
<th>@ButtonTemplateHeaderText</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
<div class="fixed-table-body">
|
||||
<table class="table table-bordered table-hover table-selected" style="margin-top: -38px;">
|
||||
<thead>
|
||||
<tr>
|
||||
@if (ShowCheckbox)
|
||||
|
@ -56,6 +80,53 @@
|
|||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table table-striped table-bordered table-hover table-selected" id="@($"{Id}_table")">
|
||||
<thead>
|
||||
<tr>
|
||||
@if (ShowCheckbox)
|
||||
{
|
||||
<th class="table-col-checkbox"><Checkbox TItem="TItem" SetCheckCallback="CheckState" ToggleCallback="ToggleCheck"></Checkbox></th>
|
||||
}
|
||||
@if (ShowLineNo)
|
||||
{
|
||||
<th class="table-col-lineno">行号</th>
|
||||
}
|
||||
@TableHeader?.Invoke(EditModel)
|
||||
@if (ShowButtons)
|
||||
{
|
||||
<th>@ButtonTemplateHeaderText</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (int index = 0; index < Items.Count(); index++)
|
||||
{
|
||||
<tr>
|
||||
@if (ShowCheckbox)
|
||||
{
|
||||
<td class="table-col-checkbox"><Checkbox TItem="TItem" Item="Items.ElementAt(index)" SetCheckCallback="item => SelectedItems.Contains(item) ? CheckBoxState.Checked : CheckBoxState.UnChecked" ToggleCallback="ToggleCheck"></Checkbox></td>
|
||||
}
|
||||
@if (ShowLineNo)
|
||||
{
|
||||
<td class="table-col-lineno">@(index + 1 + (PageIndex - 1) * PageItems)</td>
|
||||
}
|
||||
@RowTemplate?.Invoke(Items.ElementAt(index))
|
||||
@if (ShowButtons)
|
||||
{
|
||||
<td>@ButtonTemplate?.Invoke(Items.ElementAt(index))</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>@TableFooter</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
<Pagination PageItems="PageItems" TotalCount="TotalCount" PageIndex="PageIndex" OnPageClick="PageClick" OnPageItemsChange="PageItemsChange"></Pagination>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -130,6 +130,16 @@ nav .dropdown .nav-link-close.dropdown-toggle:after {
|
|||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.bootstrap-table .fixed-table-body {
|
||||
overflow: auto;
|
||||
border-radius: 4px;
|
||||
height: 300px;
|
||||
}
|
||||
|
||||
.bootstrap-table .fixed-table-body thead th, .bootstrap-table .fixed-table-header thead th {
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.table-wrapper {
|
||||
border-radius: 4px;
|
||||
overflow: auto;
|
||||
|
|
Loading…
Reference in New Issue