跳转到内容

SusTable

SusTable

轻量表头 + 可滚动行 + 分页页脚 — 与 DataTable 相同的 SusTableController,没有工具栏 / 类型化单元格外壳。

SusKit · 数据(商业)

在 Playground 中打开

SusKit · Data

属性

名称类型默认值
ControllerProp<SusTableController>new()v-model

插槽

没有插槽。

事件

没有公开事件。

样式钩子

USS 类契约 — 无需改 C# 即可覆盖外观。状态通过这些类切换:

  • sus-button
  • sus-table
  • sus-table__action-btn
  • sus-table__body
  • sus-table__cell
  • sus-table__cell--actions
  • sus-table__cell--align-center
  • sus-table__cell--align-end
  • sus-table__cell--description
  • sus-table__cell--ellipsis
  • sus-table__cell--number
  • sus-table__cell--progress
  • sus-table__footer
  • sus-table__footer-actions
  • sus-table__footer-btn
  • sus-table__footer-info
  • sus-table__header
  • sus-table__header-cell
  • sus-table__header-row
  • sus-table__header-title
  • sus-table__header-title--align-center
  • sus-table__header-title--align-end
  • sus-table__header-title--sortable
  • sus-table__media--clip
  • sus-table__media--rounded
  • sus-table__row
  • sus-table__row--hoverable
  • sus-table__row--selected
  • sus-table__row--striped
  • sus-table__rows
  • sus-table__sort-btn
  • sus-table__sort-btn--active

用法

在控制器上配置列和条目,然后把它赋给视图。

csharp
var ctrl = new SusTableController();
ctrl.SetColumns(new List<ColumnDef>
{
    new() { Key = "name", Title = "Name", Sortable = true },
    new() { Key = "role", Title = "Role", Sortable = true },
    new() { Key = "lvl", Title = "Lvl", Sortable = true },
});
ctrl.SetItems(new List<object>
{
    new Dictionary<string, object> { ["name"] = "Aria", ["role"] = "Tank", ["lvl"] = 12 },
    new Dictionary<string, object> { ["name"] = "Borin", ["role"] = "DPS", ["lvl"] = 9 },
    new Dictionary<string, object> { ["name"] = "Cira", ["role"] = "Heal", ["lvl"] = 14 },
});
ctrl.SetItemsPerPage(5);

var table = new SusTable();
table.Controller.Value = ctrl;
xml
<template>
  <sus:SusTable :Controller="TableCtrl.Value" />
</template>

<script>
public Prop<SusTableController> TableCtrl = new(new());
// Populate TableCtrl columns/items in code (see above).
</script>
Prop作用
ControllerSusTableController — 列、条目、排序、分页

说明

  • SusDataTable 更简单:没有 toolbar 插槽,没有 kind 预设外壳,单元格以纯文本渲染。
  • TotalPages > 1 时出现分页页脚。
  • 需要类型化单元格 / 全局搜索 / 选择列时 — 使用 SusDataTable