0.2.13 • Published 7 months ago

virtualized-table v0.2.13

Weekly downloads
3
License
MIT
Repository
github
Last release
7 months ago

npm version Build Status codecov NPM downloads
大数据量虚拟化表格组件

📦 安装

使用npm或yarn

npm install --save virtualized-table 
# or
yarn add virtualized-table 

使用CDN

<!-- 注意: 部署时,将 "development.umd.js" 替换为 "production.umd.min.js"-->
<script crossorigin src="https://unpkg.com/virtualized-table/dist/vtable.development.umd.js"></script>
CDNURL
unpkghttps://unpkg.com/virtualized-table/
jsDelivrhttps://jsdelivr.com/package/npm/virtualized-table

🔨 使用

示例

    import {VTablePro} from "virtualized-table";
    const columns = [
      { title: '姓名', dataIndex: 'name' },
      { title: '年龄', dataIndex: 'age' },
      { title: '住址', dataIndex: 'address' },
    ];
    const dataSource = [
      { key: '1', name: '胡彦斌', age: 32, address: '西湖区湖底公园1号' },
      { key: '2', name: '胡彦祖', age: 42, address: '西湖区湖底公园1号' },
    ];
    <VTablePro
      columns={columns}
      dataSource={dataSource}
    />

简单示例

📖 API

VTable

参数说明类型默认值
bordered是否显示边框booleanfalse
columns表格列的配置object[][]
components覆盖默认的Grid元素 {header{row, cell}, body{row, cell}}object-
columnOffsetCount表格可视区域可渲染的列数number8
columnVisibleCount表格列渲染数左右偏移量number4
dataSource数据数组object[][]
estimatedRowHeight一行的预估高度number40
estimatedColumnWidth一列的预估宽度number40
fixedLeftColumnCount左边固定列 列数number0
fixedRightColumnCount右边固定列 列数number0
fixedRowHeight固定行高(需要行合并/分组表头时设置为true)booleanfalse
headerBordered是否显示表头边框,不设置则按borderedbooleanfalse
isSticky是否使用粘性布局boolean- 看浏览器是否支持sticky
headerNotSticky表头不使用粘性布局booleanfalse
loading页面是否加载中boolean / Spin propsfalse
locale默认文案设置,目前包括空数据文案objectemptyText: 暂无数据
rowHeight表格行高number40
rowKey表格行 key 的取值,可以是字符串或一个函数string/function(record)-
rowOffsetCount表格行渲染数上下偏移量number20
rowSelection表格行是否可选择,rowSelection propsobject-
rowVisibleCount表格可视区域可渲染的行数number20
summary总结栏数据object[]-
shouldRowHeightSync是否要同步行高(isSticky=false,有固定列并且行高不固定时设置为true)booleanfalse
visibleHeight表格可视区域高度number400
onRow设置行属性function(row, realRowIndex)-

onRow 用法

<Table
  onRow={(record, index) => {
    return {
      onClick: event => {}, // 点击行
      onDoubleClick: event => {},
      onContextMenu: event => {},
      onMouseEnter: event => {}, // 鼠标移入行
      onMouseLeave: event => {},
    };
  }}
/>

columns

参数说明类型默认值
headerAlign设置列表头的对齐方式string / 'left','right','center''center'
align设置列的对齐方式string / 'left','right','center''left'
dataIndex列数据在数据项中对应的路径,暂不支持通过数组查询嵌套路径string-
ellipsis是否显示省略号booleanfalse
ellipsisTitle设置了ellipsis的列是否显示默认titlebooleantrue
key列数据的键值string-
render生成复杂数据的渲染函数,@return 里面可以设置表格行/列合并function(value, row, rowIndex, realRowIndex, column, columnIndex, realColumnIndex)-
title列头显示文字(函数用法暂不支持多级表头)ReactNode/(value, row, rowIndex)=>ReactNode-
onCell设置表头、表格、合计行属性function(column, realRowIndex)-
onHeaderCell设置表头属性function(column, realRowIndex)-
onBodyCell设置表格属性function(column, realRowIndex)-
onFooterCell设置合计行属性function(column, realRowIndex)-

render @return 合并行/列

render(value) {
  return {
    children: value,
    props: {
      colSpan: 1, // 列合并,设置为0时,不渲染(设置display:none)
      rowSpan: 1, // 行合并,设置为0时,不渲染(设置visibility:hidden)
    }
  }
}

表头分组:columnsn 可以内嵌children,以渲染分组表头。

rowSelection

参数说明类型默认值
columnWidth自定义列表选择框宽度number60
columnTitle自定义列表选择框标题string / ReactNode-
columnProps自定义列属性object-
rowRemoveVisiblehover显示行删除图标booleanfalse
selectedRowKeys指定选中项的 key 数组,需要和 onChange 进行配合string[]/number[][]
getCheckboxProps选择框的默认属性配置function(record){ return {disabled, notVisible} }-
onChange选中项发生变化时的回调function(selectedRowKeys, selectedRows)-
onSelect用户手动选择/取消选择某行的回调function(record, selected, selectedRows)-
onSelectAll用户手动选择/取消选择所有行的回调function(selected, selectedRows)-
onRowRemove点击行删除回调function(e, row, rowIndex, realRowIndex)-

Spin

参数说明类型默认值
spinning是否为加载中状态booleanfalse
spinningText加载中内容string / ReactNode-
wrapperClassName包装器的类属性string-

VTable.utils

  • VTable.utils.formatToCellsSpan(arr)
[
  {
    s: {c: 0, r: 2},
    e: {c: 1, r: 2},
  },
]

=>

{
  '0:2': {colSpan: 2, rowSpan: 1},
  '1:2': {colSpan: 0, rowSpan: 0},
}

📝 License

virtualized-table is available under the MIT License.

0.2.13

7 months ago

0.2.12

7 months ago

0.2.11

9 months ago

0.2.10

1 year ago

0.2.7

1 year ago

0.2.6

2 years ago

0.2.9

1 year ago

0.2.8

1 year ago

0.2.1

2 years ago

0.2.1-alpha-2

2 years ago

0.2.1-alpha-3

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.0-alpha.1

2 years ago

0.2.0

2 years ago

0.1.3-alpha.1

2 years ago

0.1.3-alpha.2

2 years ago

0.1.3-alpha.3

2 years ago

0.1.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.3

2 years ago

0.1.2-alpha.1

2 years ago

0.0.11-alpha.1

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11-alpha.0

4 years ago

0.0.11

4 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago