SusDataTable

带工具栏、类型化单元格、排序 / 搜索 / 分页的数据表格 — 由 SusTableController 驱动。
包
SusKit · 数据(商业)
属性
| 名称 | 类型 | 默认值 | |
|---|---|---|---|
Controller | Prop<SusTableController> | new() | v-model |
ShowToolbar | Prop<bool> | true | v-model |
Density | Prop<string> | "default" | v-model |
Variant | Prop<string> | "elevated" | v-model |
Hover | Prop<bool> | true | v-model |
插槽
| 名称 |
|---|
toolbar |
事件
没有公开事件。
样式钩子
USS 类契约 — 无需改 C# 即可覆盖外观。状态通过这些类切换:
sus-data-table__action-btnsus-data-table__cellsus-data-table__cell--actionssus-data-table__cell--align-centersus-data-table__cell--align-endsus-data-table__cell--descriptionsus-data-table__cell--numbersus-data-table__cell--selectsus-data-table__cell--togglesus-data-table__cell-wrapsus-data-table__emptysus-data-table__empty-textsus-data-table__footersus-data-table__footer-btnsus-data-table__footer-infosus-data-table__footer-leftsus-data-table__footer-rightsus-data-table__footer-selectsus-data-table__header-cellsus-data-table__header-cell--sort-wiredsus-data-table__header-cell--sortablesus-data-table__header-titlesus-data-table__header-title--align-centersus-data-table__header-title--align-endsus-data-table__header-title--sortablesus-data-table__hostsus-data-table__loading-barsus-data-table__loading-overlaysus-data-table__searchsus-data-table__sort-btnsus-data-table__sort-btn--activesus-data-table__toolbarsus-data-table__toolbar-actionssus-data-table__viewsus-data-table--density-comfortablesus-data-table--density-compactsus-data-table--hoversus-data-table--variant-flatsus-data-table--variant-outlinedsus-selectsus-select__detailssus-select__fieldsus-select__valuesus-slotsus-table__action-btnsus-table__cell--toggleunity-collection-view__itemunity-collection-view__item--selectedunity-list-view__itemunity-list-view__item--alternatedunity-list-view__item--selectedunity-multi-column-headerunity-multi-column-header__columnunity-multi-column-header__column__sort-indicatorunity-multi-column-header__column-sortingunity-multi-column-header__column-sorting-indicator
用法
列和行定义在控制器上(SetColumns / SetItems)。可选的 ApplyKindDefaults 应用一个 SusTableKind 预设。
csharp
var ctrl = new SusTableController();
ctrl.ApplyKindDefaults(SusTableKind.MainList);
ctrl.SetColumns(new List<ColumnDef>
{
new() { Key = "Name", Title = "Name", MinWidth = 140f, Sortable = true, Searchable = true },
new() { Key = "Role", Title = "Role", Width = 100f, Sortable = true },
new() { Key = "Level", Title = "Lvl", Width = 72f, Align = "end",
CellType = SusCellType.Number, Sortable = true },
});
ctrl.SetItems(new List<object>
{
new Dictionary<string, object> { ["Name"] = "Aria", ["Role"] = "Tank", ["Level"] = 12 },
new Dictionary<string, object> { ["Name"] = "Borin", ["Role"] = "DPS", ["Level"] = 9 },
});
ctrl.SetItemsPerPage(5);
var table = new SusDataTable();
table.Controller.Value = ctrl;
table.ShowToolbar.Value = true;
table.Density.Value = "default";
table.Variant.Value = "elevated";
table.Hover.Value = true;xml
<template>
<sus:SusDataTable :Controller="TableCtrl.Value"
:ShowToolbar="ShowToolbar.Value"
:Density="Density.Value"
:Variant="Variant.Value"
:Hover="Hover.Value">
<template #toolbar>
<!-- Optional actions next to global search -->
</template>
</sus:SusDataTable>
</template>
<script>
public Prop<SusTableController> TableCtrl = new(new());
public Prop<bool> ShowToolbar = new(true);
public Prop<string> Density = new("default");
public Prop<string> Variant = new("elevated");
public Prop<bool> Hover = new(true);
// Populate TableCtrl columns/items in code (see above).
</script>| Prop | 作用 |
|---|---|
Controller | SusTableController — 列、条目、排序、搜索、分页 |
ShowToolbar | 全局搜索 + toolbar 插槽 |
Density | default · compact · comfortable |
Variant | elevated · flat · outlined |
Hover | 行悬停高亮 |
说明
- 需要工具栏、kind 预设或类型化单元格(
SusCellType:text · number · icon · image · toggle · badge · progress · description · actions)时,优先用SusDataTable而不是SusTable。 SusTableKind:MainList·Picker·ActionList·ReadOnly·Dev— 通过ApplyKindDefaults应用。- 行操作 / 选择 / 加载状态定义在控制器上(
Options、RowActionRequested、Loading等)。 - 空
Items显示内置空状态;设置Loading显示遮罩加载条。