跳转到内容

Table 数据容器

表格 Table

以列表形式展示模型数据,支持行操作

API

通用属性见: 容器通用属性

参数说明类型默认值
groupCountField使用指定字段进行分组展示,目前只支持枚举类型string-
pagination是否显示分页booleantrue
order指定排序字段的升序或降序,和 orderField 联合使用,可选值:desc|ascstring-
orderField指定排序的字段string-
fuzzySearchable是否显示模糊搜索booleantrue
defaultShowFilter是否默认显示搜索booleantrue
onRowClick选中行时触发的 Action, 可以指定一个 action key 或一个方法(参数为行数据)string |(record)=>void-
defaultExpandAllRows默认展开所有行(行数据需要返回 id)booleanfalse
onUpdate单元格编辑保存触发的 Action, 在 Table 和 Detail 中如果配了 editable 需要配置string-
serialNumber序号显示规则,boolean pageIncrease |((record: any, index: number) => any)-
genSummaryData生成表格下面统计行数据的方法(data: record [])=>[{label: string, value: string}] | undefined-
singleSelection单选(配合 Action 上的 multi 才能使用)booleanfalse
rowSelectDisabled设置选择项不可选(record: IDictionary) => boolean-
groupCountFilter获取 table 筛选集合(options: GroupItem[]) => GroupItem[]-
advanced高级表格类型(表格充满操作和列筛选排序操作)booleantrue
fuzzySearchable是否可支持表格关键字查询模糊搜索booleantrue
columnOrder是否可支持列排序booleantrue
enableExport是否可支持导出功能booleanfalse
maxCount最大显示条数number-

serialNumber: 序号显示规则 true 为翻页从 1 开始计数, false 为不显示, pageIncrease 为翻页累计计数,  还可以为一个方法:@serialNumber="(record) => record.sn"

table 作为 lookupFrom 关联的数据容器刷新需要调用主数据容器的 refresh

<Action label="删除" action="xxx" @after="() => getContainerByKey('mainContainerKey').refresh()"/>

table 数据容器可以额外的配置 Search 节点指定哪些字段可以用于搜索.

Search

参数说明类型默认值
onSearchValueChangeSearch 中搜索项值发生变化时的回调(changedValue, fieldName)=> void-

Fields

参数说明类型默认值
fullMatch用于 Search 中的字段,指定搜索的字段是否采用精确匹配booleanfalse
singleInSearch该参数仅用于 <Search>  内的 <Field>  上,配置字段类型为 Boolen/Enum/EnumMulti/ToOne/ToMany  的字段是否为单选; Int/Number/Float/Date/Time/DateTime 的字段是否为范围选择boolenfalse

可以通过onSearchValueChange联动搜索项的值

<View title="用户">
<Table key="table" model="user2_User">
<Search>
<Fields @onSearchValueChange="onSearchValueChange">
<Field name="address" />
<Field name="username" />
</Fields>
</Search>
<Fields>
<Field name="age" :singleInSearch="true">
<Field name="username" :fullMatch="true"/>
<Field name="address"/>
</Fields>
<Actions>
<Action openViewType="Dialog" label="批量" multi action="CUSTOM_User_ReName" />
</Actions>
</Table>
</View>

通用标签见: 容器通用标签

Table 多选

可以通过在 Actions/Action 上配置 multi 属性支持 table 多选操作

<View title="用户">
<Table key="table" model="user2_User">
<Fields>
<Field name="address" />
<Field name="username" />
</Fields>
<Actions>
<Action openViewType="Dialog" label="批量" multi action="CUSTOM_User_ReName" />
</Actions>
</Table>
</View>

用法

基础表格

<View title="人员列表">
<Table key="person" model="trantor_doc_Person">
<Alert type="normal" message="这是一个提示信息" />
<Fields>
<Field name="name"/>
<Field name="avatar"/>
<Field name="age"/>
<Field name="password"/>
<Field name="credentials"/>
<Field label="部门名称" name="department.name"/>
<Field name="birthday"/>
<GroupField title="嵌套字段">
<Field name="name"/>
<Field name="age"/>
</GroupField>
</Fields>
</Table>
</View>
表格搜索
<View title="人员列表">
<Table key="person" model="trantor_doc_Person" order="asc" orderField="age" >
<Search @onSearchValueChange="onSearchValueChange">
<Fields>
<Field fullMatch name="name"/>
<Field singleInSearch name="age"/>
<Field name="credentials"/>
<Field name="department"/>
</Fields>
</Search>
<!-- 配置列表展示字段 -->
<Fields>
<Field name="name"/>
<Field name="avatar"/>
<Field name="age"/>
<Field name="password"/>
<Field name="credentials"/>
<Field label="部门名称" name="department.name"/>
<Field name="birthday"/>
</Fields>
</Table>
</View>
表格操作
<View title="人员列表">
<Table key="person" model="trantor_doc_Person" serialNumber
@genSummaryData="handlerSummary"
@onRowClick="handlerRowlick"
onUpdate="trantor_doc_Person_update" >
<!-- 配置列表展示字段 -->
<Fields>
<!-- name可编辑 配合table的onUpdate方法使用 -->
<Field name="name" editable/>
<Field name="avatar"/>
<Field name="age"/>
<Field name="password"/>
<Field name="credentials"/>
<Field label="部门名称" name="department.name"/>
<Field name="birthday"/>
</Fields>
<!-- 配置行数据行为 -->
<RecordActions label="操作">
<Action action="trantor_doc_Person_delete" after="Refresh" label="删除"/>
<Action action="edit" after="Refresh" label="编辑"/>
<Action action="detail" label="详情"/>
</RecordActions>
</Table>
</View>
groupCountField
<View title="公司">
<Table model="trantor_doc_Company" groupCountField='type'>
<Search>
<Fields>
<Field name='name'></Field>
</Fields>
</Search>
<Fields>
<Field name="name"/>
<Field name='type'/>
</Fields>
</Table>
</View>
单选和禁用可选项
<View title="公司">
<Table model="trantor_doc_Company" singleSelection @rowSelectDisabled="rowSelectDisabled">
<Search>
<Fields>
<Field name='name'></Field>
</Fields>
</Search>
<Fields>
<Field name="name"/>
<Field name='type'/>
</Fields>
<Actions>
<Action layout='Header' multi label='test' @action='getContext'/>
</Actions>
</Table>
</View>