valueEnum支持自定义色值,status值不区分大小写 (#660)
重要: 此仓库后续不再维护,也不再接受更多的特性更新。ant-design/pro-table 将会迁移至 ant-design/pro-components 仓库进行后续的维护,访问 https://procomponents.ant.design/table 了解更多。此变更不影响继续使用 @ant-design/pro-table 这个 npm 包名安装使用此组件。
ant-design/pro-table
ant-design/pro-components
@ant-design/pro-table
English
🏆 Use Ant Design Table like a Pro!
codesandbox
pro-table 在 antd 的 table 上进行了一层封装,支持了一些预设,并且封装了一些行为。这里只列出与 antd table 不同的 api。
(params?: {pageSize: number;current: number;[key: string]: any;}) => Promise<RequestData<T>>
(data: T[]) => T[]
T[]
React.MutableRefObject<ActionType> | ((actionRef: ActionType) => void)
(action: UseFetchDataAction<RequestData<T>>) => React.ReactNode[]
(dataSource: T[]) => void
(e: Error) => void
{{ fullScreen: boolean | function, reload: boolean | function,setting: true }}
{ fullScreen: true, reload:true, setting: true}
"string" | "number" | false
(params:T)=>T
"form"
FormProps
(collapsed: boolean,showCollapseButton?: boolean,) => React.ReactNode
(collapsed: boolean) => void;
(( searchConfig: Omit<SearchConfig, 'optionRender'>, props: Omit<FormOptionProps, 'searchConfig'>, ) => React.ReactNode) | false;
(text: any,record: T,index: number,action: UseFetchDataAction<RequestData<T>>) => string
(text: React.ReactNode,record: T,index: number,action: UseFetchDataAction<RequestData<T>>) => React.ReactNode | React.ReactNode[]
(item,props:{value,onChange}) => React.ReactNode
'money' | 'option' | 'date' | 'dateTime' | 'time' | 'text'| 'index' | 'indexBorder'
boolean | object[]
{ [prop: string]: any }
有些时候我们要触发 table 的 reload 等操作,action 可以帮助我们做到这一点。
interface ActionType { reload: () => void; fetchMore: () => void; reset: () => void; reloadAndRest: () => void; } const ref = useRef<ActionType>(); <ProTable actionRef={ref} />; // 刷新 ref.current.reload(); // 重置所有项并刷新 ref.current.reloadAndRest(); // 加载更多 ref.current.fetchMore(); // 重置到默认值 ref.current.reset(); // 清空选中项 ref.current.clearSelected();
现在支持的值如下
[<a>操作a</a>,<a>操作b</a>]
当前列值的枚举
interface IValueEnum { [key: string]: | React.ReactNode | { text: React.ReactNode; status: 'Success' | 'Error' | 'Processing' | 'Warning' | 'Default'; }; }
npm install @ant-design/pro-table # or yarn add @ant-design/pro-table
import React, { useState } from 'react'; import ProTable, { ProColumns } from '@ant-design/pro-table'; import { Input, Button } from 'antd'; const columns: ProColumns[] = [ { title: 'Name', dataIndex: 'name', copyable: true, }, { title: 'Age', dataIndex: 'age', }, { title: 'date', dataIndex: 'date', valueType: 'date', }, { title: 'option', valueType: 'option', dataIndex: 'id', render: (text, row, index, action) => [ <a onClick={() => { window.alert('确认删除?'); action.reload(); }} > delete </a>, <a onClick={() => { window.alert('确认刷新?'); action.reload(); }} > reload </a>, ], }, ]; export default () => { const [keywords, setKeywords] = useState(''); return ( <ProTable<{}, { keywords: string }> size="small" columns={columns} request={() => ({ data: [ { name: 'Jack', age: 12, date: '2020-01-02', }, ], success: true, })} rowKey="name" params={{ keywords }} toolBarRender={(action) => [ <Input.Search style={{ width: 200, }} onSearch={(value) => setKeywords(value)} />, ]} pagination={{ defaultCurrent: 10, }} /> ); };
MIT
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
此仓库已废弃
重要: 此仓库后续不再维护,也不再接受更多的特性更新。
ant-design/pro-table将会迁移至ant-design/pro-components仓库进行后续的维护,访问 https://procomponents.ant.design/table 了解更多。此变更不影响继续使用@ant-design/pro-table这个 npm 包名安装使用此组件。English
@ant-design/pro-table
🏆 Use Ant Design Table like a Pro!
Demo
codesandbox
API
pro-table 在 antd 的 table 上进行了一层封装,支持了一些预设,并且封装了一些行为。这里只列出与 antd table 不同的 api。
Table
(params?: {pageSize: number;current: number;[key: string]: any;}) => Promise<RequestData<T>>(data: T[]) => T[]T[]React.MutableRefObject<ActionType> | ((actionRef: ActionType) => void)(action: UseFetchDataAction<RequestData<T>>) => React.ReactNode[](dataSource: T[]) => void(e: Error) => void{{ fullScreen: boolean | function, reload: boolean | function,setting: true }}{ fullScreen: true, reload:true, setting: true}"string" | "number" | false(params:T)=>T"form"FormPropssearch
(collapsed: boolean,showCollapseButton?: boolean,) => React.ReactNode(collapsed: boolean) => void;(( searchConfig: Omit<SearchConfig, 'optionRender'>, props: Omit<FormOptionProps, 'searchConfig'>, ) => React.ReactNode) | false;Columns
(text: any,record: T,index: number,action: UseFetchDataAction<RequestData<T>>) => string(text: React.ReactNode,record: T,index: number,action: UseFetchDataAction<RequestData<T>>) => React.ReactNode | React.ReactNode[](item,props:{value,onChange}) => React.ReactNode'money' | 'option' | 'date' | 'dateTime' | 'time' | 'text'| 'index' | 'indexBorder'boolean | object[]{ [prop: string]: any }ActionType
有些时候我们要触发 table 的 reload 等操作,action 可以帮助我们做到这一点。
valueType
现在支持的值如下
[<a>操作a</a>,<a>操作b</a>]valueEnum
当前列值的枚举
Usage
LICENSE
MIT