All Projects → ant-design → Pro Table

ant-design / Pro Table

Licence: mit
🏆 Use Ant Design Table like a Pro!

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Pro Table

antd-etable
Editable Table base on Ant Design
Stars: ✭ 43 (-92.08%)
Mutual labels:  table, antd, ant-design
ant-table-extensions
Export, Search extensions to Ant Design's Table component.
Stars: ✭ 43 (-92.08%)
Mutual labels:  table, antd, ant-design
Formik Antd
Simple declarative bindings for Ant Design and Formik.
Stars: ✭ 453 (-16.57%)
Mutual labels:  antd, ant-design
Antd Table Infinity
An infinite scroll component based on antd-table that supports virtual scrolling
Stars: ✭ 255 (-53.04%)
Mutual labels:  antd, table
Antd Visual Editor
ant-design 组件库实时可视化编辑器,实时生成 react 代码
Stars: ✭ 482 (-11.23%)
Mutual labels:  antd, ant-design
GOSH-FHIRworks2020-React-Dashboard
🩺 Fully Responsive FHIR Dashboard written using @reactjs for NHS and GOSH hackathon
Stars: ✭ 21 (-96.13%)
Mutual labels:  antd, ant-design
erp-crm
IDURAR is Open Source ERP/CRM Based on Mern Stack (Node.js / Express.js / MongoDb / React.js ) with Ant Design (AntD) and Redux
Stars: ✭ 18 (-96.69%)
Mutual labels:  antd, ant-design
Jeecg Boot
「企业级低代码平台」前后端分离架构SpringBoot 2.x,SpringCloud,Ant Design&Vue,Mybatis-plus,Shiro,JWT。强大的代码生成器让前后端代码一键生成,无需写任何代码! 引领新的开发模式OnlineCoding->代码生成->手工MERGE,帮助Java项目解决70%重复工作,让开发更关注业务,既能快速提高效率,帮助公司节省成本,同时又不失灵活性。
Stars: ✭ 26,432 (+4767.77%)
Mutual labels:  antd, ant-design
umi-plugin-antd-theme
🎨 Best theme plugin
Stars: ✭ 77 (-85.82%)
Mutual labels:  antd, ant-design
React Admin
基于 Ant Design React 的管理系统架构
Stars: ✭ 376 (-30.76%)
Mutual labels:  antd, ant-design
React Spa
React Redux,适合中大型规模应用开发,注释还算详细,配置有TypeScript、 CSS Modules、React-Router 4、koa接口mock请求等。接口埋点报错统一处理。
Stars: ✭ 327 (-39.78%)
Mutual labels:  antd, ant-design
Ant Design Dark Theme
🌚 Dark theme variables of Ant Design
Stars: ✭ 431 (-20.63%)
Mutual labels:  antd, ant-design
gatsby-wordpress-typescript-scss-blog
Gatsby Wordpress Typescript Blog Boilerplate
Stars: ✭ 50 (-90.79%)
Mutual labels:  antd, ant-design
react-drag
A drag and drop platform based on sortable.js front-end visualization. 一个基于sortable.js的前端可视化搭建的拖拽平台,ui组件采用antd-mobile.通过umi脚手架构建.技术栈采用dva+hooks+umi+antd-mobile+sortable.js+react-color.
Stars: ✭ 51 (-90.61%)
Mutual labels:  antd, ant-design
Ant Design Icons
⭐ Ant Design SVG Icons
Stars: ✭ 484 (-10.87%)
Mutual labels:  antd, ant-design
redux-form-antd
Ant design bindings for redux form
Stars: ✭ 107 (-80.29%)
Mutual labels:  antd, ant-design
Bird Front
bird前端项目,基于react、antd、antd-admin,封装常用数据组件,细粒度权限解决方案。
Stars: ✭ 272 (-49.91%)
Mutual labels:  antd, ant-design
Sunflower
🦹 Process components for antd4 & antd3 by alipay industry technology
Stars: ✭ 441 (-18.78%)
Mutual labels:  antd, ant-design
antd-pro-toolkit
🐜ant design pro toolkit.
Stars: ✭ 13 (-97.61%)
Mutual labels:  antd, ant-design
Ant Design Blazor
🌈A set of enterprise-class UI components based on Ant Design and Blazor WebAssembly.
Stars: ✭ 3,890 (+616.39%)
Mutual labels:  antd, ant-design

此仓库已废弃

重要: 此仓库后续不再维护,也不再接受更多的特性更新。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

属性 描述 类型 默认值
request 一个获得 dataSource 的方法 (params?: {pageSize: number;current: number;[key: string]: any;}) => Promise<RequestData<T>> -
postData 对通过 url 获取的数据进行一些处理 (data: T[]) => T[] -
defaultData 默认的数据 T[] -
actionRef get table action React.MutableRefObject<ActionType> | ((actionRef: ActionType) => void) -
toolBarRender 渲染工具栏,支持返回一个 dom 数组,会自动增加 margin-right (action: UseFetchDataAction<RequestData<T>>) => React.ReactNode[] -
onLoad 数据加载完成后触发,会多次触发 (dataSource: T[]) => void -
onRequestError 数据加载失败时触发 (e: Error) => void -
tableClassName 封装的 table 的 className string -
tableStyle 封装的 table 的 style CSSProperties -
headerTitle 左上角的 title React.ReactNode -
options table 的工具栏,设置为 false 可以关闭它 {{ fullScreen: boolean | function, reload: boolean | function,setting: true }} { fullScreen: true, reload:true, setting: true}
search 是否显示搜索表单,传入对象时为搜索表单的配置 search config true
dateFormatter moment 的格式化方式 "string" | "number" | false string
beforeSearchSubmit 搜索之前进行一些修改 (params:T)=>T -
onSizeChange table 尺寸发生改变 `(size: 'default' 'middle'
columnsStateMap columns 的状态枚举 `{[key: string]: { show:boolean, fixed: "right" "left"} }`
onColumnsStateChange columns 状态发生改变 `(props: {[key: string]: { show:boolean, fixed: "right" "left"} }) => void`
type pro-table 类型 "form" -
form antd form 的配置 FormProps -

search

属性 描述 类型 默认值
searchText 查询按钮的文本 string 查询
resetText 重置按钮的文本 string 重置
submitText 提交按钮的文本 string 提交
collapseRender 收起按钮的 render (collapsed: boolean,showCollapseButton?: boolean,) => React.ReactNode -
collapsed 是否收起 boolean -
onCollapse 收起按钮的事件 (collapsed: boolean) => void; -
optionRender 操作栏的 render (( searchConfig: Omit<SearchConfig, 'optionRender'>, props: Omit<FormOptionProps, 'searchConfig'>, ) => React.ReactNode) | false; -

Columns

属性 描述 类型 默认值
renderText 类似 table 的 render,但是必须返回 string,如果只是希望转化枚举,可以使用 valueEnum (text: any,record: T,index: number,action: UseFetchDataAction<RequestData<T>>) => string -
render 类似 table 的 render,第一个参数变成了 dom,增加了第四个参数 action (text: React.ReactNode,record: T,index: number,action: UseFetchDataAction<RequestData<T>>) => React.ReactNode | React.ReactNode[] -
renderFormItem 渲染查询表单的输入组件 (item,props:{value,onChange}) => React.ReactNode -
ellipsis 是否自动缩略 boolean -
copyable 是否支持复制 boolean -
valueEnum 值的枚举,会自动转化把值当成 key 来取出要显示的内容 valueEnum -
valueType 值的类型 'money' | 'option' | 'date' | 'dateTime' | 'time' | 'text'| 'index' | 'indexBorder' 'text'
hideInSearch 在查询表单中不展示此项 boolean -
hideInTable 在 Table 中不展示此列 boolean -
hideInForm 在 Form 模式下 中不展示此列 boolean -
filters 表头的筛选菜单项,当值为 true 时,自动使用 valueEnum 生成 boolean | object[] false
order 决定在 查询表单中的顺序,越大越在前面 number -
formItemProps 查询表单的 props,会透传给表单项 { [prop: string]: any } -

ActionType

有些时候我们要触发 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();

valueType

现在支持的值如下

类型 描述 示例
money 转化值为金额 ¥10,000.26
date 日期 2019-11-16
dateRange 日期区间 2019-11-16 2019-11-18
dateTime 日期和时间 2019-11-16 12:50:00
dateTimeRange 日期和时间区间 2019-11-16 12:50:00 2019-11-18 12:50:00
time 时间 12:50:00
option 操作项,会自动增加 marginRight,只支持一个数组,表单中会自动忽略 [<a>操作a</a>,<a>操作b</a>]
text 默认值,不做任何处理 -
textarea 与 text 相同, form 转化时会转为 textarea 组件 -
index 序号列 -
indexBorder 带 border 的序号列 -
progress 进度条 -
digit 单纯的数字,form 转化时会转为 inputNumber -

valueEnum

当前列值的枚举

interface IValueEnum {
  [key: string]:
    | React.ReactNode
    | {
        text: React.ReactNode;
        status: 'Success' | 'Error' | 'Processing' | 'Warning' | 'Default';
      };
}

Usage

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,
      }}
    />
  );
};

LICENSE

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].