-
-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: over strecth logic * test: add test case
- Loading branch information
Showing
6 changed files
with
154 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: Virtual Columns | ||
nav: | ||
title: Demo | ||
path: /demo | ||
--- | ||
|
||
<code src="../examples/virtual-columns.tsx"></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React from 'react'; | ||
import '../../assets/index.less'; | ||
import { VirtualTable } from '../../src'; | ||
import type { ColumnsType } from '../../src/interface'; | ||
|
||
interface RecordType { | ||
a: string; | ||
b?: string; | ||
c?: string; | ||
} | ||
|
||
const columns1: ColumnsType = [ | ||
{ title: 'title1', dataIndex: 'a', width: 100 }, | ||
{ title: 'title2', dataIndex: 'b', width: 100 }, | ||
{ | ||
title: 'title13', | ||
dataIndex: 'c', | ||
}, | ||
]; | ||
|
||
const columns2: ColumnsType = [ | ||
{ title: 'title1', dataIndex: 'a', width: 100 }, | ||
{ title: 'title2', dataIndex: 'b', width: 100 }, | ||
]; | ||
|
||
const columns3: ColumnsType = [ | ||
{ title: 'title1', dataIndex: 'a', width: 500 }, | ||
{ title: 'title2', dataIndex: 'b', width: 500 }, | ||
]; | ||
|
||
const data: RecordType[] = new Array(4 * 10000).fill(null).map((_, index) => ({ | ||
a: `a${index}`, | ||
b: `b${index}`, | ||
c: `c${index}`, | ||
})); | ||
|
||
const Demo = () => { | ||
const [columns, setColumns] = React.useState(columns1); | ||
|
||
return ( | ||
<div style={{ width: 800, padding: `0 64px` }}> | ||
<label> | ||
<input type="radio" checked={columns === columns1} onChange={() => setColumns(columns1)} /> | ||
Fill Rest | ||
</label> | ||
<label> | ||
<input type="radio" checked={columns === columns2} onChange={() => setColumns(columns2)} /> | ||
Stretch | ||
</label> | ||
<label> | ||
<input type="radio" checked={columns === columns3} onChange={() => setColumns(columns3)} /> | ||
Over Size | ||
</label> | ||
|
||
<VirtualTable | ||
getContainerWidth={(_, w) => w - 1} | ||
columns={columns} | ||
scroll={{ y: 200 }} | ||
data={data} | ||
rowKey="a" | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Demo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84a5b44
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
table – ./
table-git-master-react-component.vercel.app
table-react-component.vercel.app