1.0.5 • Published 2 years ago

fydatagrid v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

BOSS、PRINT、PROCESS、FORM 代码仓库

features

  • 分页
  • 拖拽调整列宽
  • 表头排序
  • 表头筛选
  • 行选择
  • ......

使用

// 安装
npm i fydatagrid -S

// 查看demo
npm start
<DataGrid
  dataSource={dataSource}
  rowKey="id"
  columns={columns}
  pagination={false}
  // 必须指定宽高,也可以指定maxWidth或maxHeight
  style={{
    width: "100%",
    height: 300
  }}
/>

API

参数类型说明默认值
columnsColumn列配置
dataSourceArray数组数据
defaultFilter{ key in string : any }默认过滤参数 |
defaultSort{ key in string : 'ASC' | 'DESC' }默认排序参数
filter{ key in string : any }过滤参数 |
loadingboolean加载中状态false
onFilterChange(filter: ColumnItem'filter') => void过滤条件发生变化时的回调函数
onSortChange(sort: ColumnItem'sort') => void排序条件变化时的回调函数
paginationPagination使用了ant design的分页组件
rowKeystring | (record, index) => string表格行 key 的取值
rowSelection
sort{ key in string : 'ASC' | 'DESC' }排序参数
frontendboolean前端模式(开启后组件会自动实现分页、筛选、排序)false

Column

参数类型说明默认值
dataIndexstring列显示数据的字段名
defaultSortOrder'ASC' | 'DESC'默认的排序
filterAct'modal' | 'dropdown' | 'customize'点击筛选后筛选组件交互方式
filterCallback(value: any, filter: any) => any[]filterMode为callback时调用的筛选函数
filterConfigFilterConfig
filterMode'eq' | 'like' | 'contain' | 'between' | 'callback'筛选时匹配的方式
filterRender() => ReactNodefilterType为customize时渲染的筛选组件
filterType'input' | 'checkboxList' | 'dateRange' | 'dateTimeRange' | 'customize'筛选组件类型
fixed'left' | 'right' | boolean固定列false
renderfunction(field, record, index)渲染函数
titleReactNode标题
widthnumber初始宽度
sorterboolean | Function排序函数,后端排序时可以设置为true
sortDirectionsArray<'ASC' | 'DESC'>点击排序时排序切换的顺序'ASC', 'DESC'

FilterConfig

参数类型说明默认值
filterKeystring指定筛选时的字段名称(如‘name.firstName’)Column'key' | Column'dataIndex'
onClick(e) => void点击筛选图标时的回调函数
optionsArray<{label: string; value: any;}>filterType为checkboxList时筛选组件展示的列表
placeholderstringfilterType为input时的placeholder

RowSelection

参数类型说明默认值
selectedRowKeysArray指定哪些列被选中
defaultSelectedRowKeysArray指定哪些列默认被选中
type'checkbox' | 'radio'单选/多选
onChange(selectedRowKeys: RowSelection'selectedRowKeys', selectedRows: any[]) => void行选择变化时的回调函数
onSelect(record: any, selected: boolean, selectedRows: any[], nativeEvent) => void手动选择/取消选择某行的回调
onSelectAll(selected: boolean, selectedRows: any[]) => void手动选择/取消选择所有行的回调