# Search-Table 查询表格
# install
tnpm i -S @sula-template/search-table
# usage
import SearchTable from "@sula-template/search-table";
# API
# ref
获取 table 实例
function () {
const tableRef = React.useRef(null);
return <SearchTable ref={tableRef} />
}
# quickSearch
快速搜索配置,显示在表格左上角,提供对表格针对某一关键字进行快速搜索的能力
示例:
{
quickSearch:
{
name: "name",
render: {
type: "search",
props: {
placeholder: "Search name"
}
}
}
}
使用 tips:
render.type
可配置search
类型,支持回车搜索能力- 只有一项快速搜索内容时,type 不传默认是
search
类型,如不需要,配置成 input 即可 - 超过一项快速搜索内容时,默认展现右侧搜索按钮
- 为了保证体验,建议最多放置不超过 3 个搜索控件
# advancedSearchFields
- 类型:
Array<
Field>
- 默认值:
-
顶部高级搜索表单项配置列表
使用 tips:
- 默认隐藏,点击表格左上角 more 展开
- 适用于高级搜索场景
# searchFields
- 类型:
Array<
Field>
- 默认值:
-
顶部一般搜索表单项配置列表
使用 tips:
- 搜索表单直接展示不支持隐藏切换,不支持快速搜索能力配置
- 适用于一般搜索场景
# layout
- 类型:
vertical | horizontal | inline
- 默认值:
vertical
顶部搜索表单布局配置 👉 配置同 sula-form layout
# itemLayout
- 类型:
object
- 默认值:
{span: 8}
顶部搜索表单中,表单项内部布局分布 👉 配置同 sula-form itemLayout
# remoteDataSource
- 类型: FetchType
- 默认值:
-
表格后端分页请求配置 👉 配置同 sula-table remoteDataSource
提示
remoteDataSource 如果希望添加额外请求参数,可以在 convertParams 中添加,也可以在 extraParams 中添加(params被分页信息占用)
# columns
- 类型:
Array<
Column>
- 默认值:
-
表格列配置,👉 配置同 sula-table columns
# batchActions
- 类型:
Array<
RenderType>
- 默认值:
-
扩展右上角按钮,批量操作
示例:
batchActions: [
{
text: "Delete",
props: {
icon: "minus",
type: "danger",
shape: "round"
},
action: {
type: "fetch"
}
}
];
# create
- 类型:RenderType
- 默认值:
-
新增按钮
示例:
create: {
text: 'Create',
path: '',
query: { aaa: 11 },
type: 'button',
props: {
icon: 'plus',
type: 'success',
shape: 'round',
},
}
# actions
- 类型:
Array<
RenderType>
- 默认值:
-
扩展右上角按钮,一般操作
示例:
actions: [
{
text: "Create",
path: "",
query: { aaa: 11 },
type: "button",
props: {
icon: "plus",
type: "success",
shape: "round"
}
},
{
text: "Edit",
path: "",
type: "button",
props: {
icon: "edit",
shape: "round"
}
}
];
使用 tips:
- actions优先级大于create
# leftActions
- 类型:
Array<
RenderType>
- 默认值:
-
无 quickSearch 场景使用,保证界面视觉饱满
示例:
leftActions: [
{
type: "tabletitle",
title: "It's Title"
}
];
# rowKey
- 类型:
string|(record) => string
- 默认值:
-
表格行 key 的取值,可以是字符串或一个函数
# autoInit
- 类型:
boolean
- 默认值:
true
表单初始是否自动发起一次后端分页请求
# disableClearSelectedRows
- 类型:
boolean
- 默认值:
false
调用refresh时是否清空选中行
# enableQuickSearchBackground
- 类型:
boolean
- 默认值:
false
快速搜索是否显示白色背景
# initialValues
- 类型:
object
- 默认值:
-
表格初始化时搜索的初始值
注意
- 仅在初始设置时生效,不会随设置值的改变而变化
# tableProps
- 类型:TableProps
- 默认值:
-
其他表格配置,详细配置请查看sula-table
# 支持非分页搜索与过滤
{
tableProps: {
initialPaging: {pagination: false}
}
}
# formProps
- 类型:FormProps
- 默认值:
-
表单其他配置,详细配置请查看sula-form