Skip to content

Commit fdc83d0

Browse files
committedApr 22, 2021
feat: adding resizable
1 parent 19f43e2 commit fdc83d0

File tree

4 files changed

+85
-2
lines changed

4 files changed

+85
-2
lines changed
 

‎docs/examples/resizable.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: Resizable columns
3+
keywords:
4+
- javascript
5+
- table
6+
- javascript table
7+
- gridjs
8+
- grid js
9+
- resizable columns
10+
- resize columns
11+
---
12+
13+
import { LiveExample } from "../../lib/liveExample.js";
14+
15+
Simply add `resizable: true` to your config to enable resizable columns:
16+
17+
<LiveExample children={
18+
`
19+
const grid = new Grid({
20+
columns: ['Name', 'Email', 'Phone Number'],
21+
data: [
22+
['John', 'john@example.com', '(353) 01 222 3333'],
23+
['Mark', 'mark@gmail.com', '(01) 22 888 4444']
24+
],
25+
resizable: true,
26+
sort: true
27+
});
28+
`
29+
} />
30+
31+
You can also set width before passing the `resizable` flag:
32+
33+
<LiveExample children={
34+
`
35+
const grid = new Grid({
36+
columns: ['Name', 'Email', 'Phone Number'],
37+
data: [
38+
['John', 'john@example.com', '(353) 01 222 3333'],
39+
['Mark', 'mark@gmail.com', '(01) 22 888 4444']
40+
],
41+
width: 500,
42+
resizable: true
43+
});
44+
`
45+
} />

‎docs/examples/wide-table.md

+37
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { LiveExample } from "../../lib/liveExample.js";
1616

1717
Grid.js supports wide tables, too:
1818

19+
20+
1921
<LiveExample children={
2022
`
2123
const grid = new Grid({
@@ -46,3 +48,38 @@ const grid = new Grid({
4648
:::tip
4749
Grid.js automatically calculates the width of columns when `autoWidth` is set to `true`
4850
:::
51+
52+
You can also change the way column widths are calculated. In this example, we are adding `white-space: nowrap` to the entire
53+
table:
54+
55+
<LiveExample children={
56+
`
57+
const grid = new Grid({
58+
columns: [
59+
'Name',
60+
'Email',
61+
'Title',
62+
'Company',
63+
'Country',
64+
'County',
65+
],
66+
style: {
67+
table: {
68+
'white-space': 'nowrap'
69+
}
70+
},
71+
sort: true,
72+
pagination: true,
73+
data: Array(50).fill().map(x => [
74+
faker.name.findName(),
75+
faker.internet.email(),
76+
faker.name.title(),
77+
faker.company.companyName(),
78+
faker.address.country(),
79+
faker.address.county(),
80+
])
81+
});
82+
`
83+
} />
84+
85+
<br/>

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
},
1212
"dependencies": {
1313
"@docusaurus/core": "^2.0.0-alpha.72",
14-
"@docusaurus/preset-classic": "^2.0.0-alpha.71",
15-
"@docusaurus/theme-live-codeblock": "^2.0.0-alpha.71",
14+
"@docusaurus/preset-classic": "^2.0.0-alpha.72",
15+
"@docusaurus/theme-live-codeblock": "^2.0.0-alpha.72",
1616
"@emotion/css": "^11.1.3",
1717
"chartist": "^0.11.4",
1818
"classnames": "^2.3.1",

‎sidebars.js

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module.exports = {
4545
'examples/pagination',
4646
'examples/search',
4747
'examples/sorting',
48+
'examples/resizable',
4849
'examples/loading-state',
4950
'examples/wide-table',
5051
'examples/fixed-header',

0 commit comments

Comments
 (0)
Please sign in to comment.