File tree 4 files changed +85
-2
lines changed
4 files changed +85
-2
lines changed Original file line number Diff line number Diff line change
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
+ } />
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ import { LiveExample } from "../../lib/liveExample.js";
16
16
17
17
Grid.js supports wide tables, too:
18
18
19
+
20
+
19
21
<LiveExample children={
20
22
`
21
23
const grid = new Grid({
@@ -46,3 +48,38 @@ const grid = new Grid({
46
48
::: tip
47
49
Grid.js automatically calculates the width of columns when ` autoWidth ` is set to ` true `
48
50
:::
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 />
Original file line number Diff line number Diff line change 11
11
},
12
12
"dependencies" : {
13
13
"@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 " ,
16
16
"@emotion/css" : " ^11.1.3" ,
17
17
"chartist" : " ^0.11.4" ,
18
18
"classnames" : " ^2.3.1" ,
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ module.exports = {
45
45
'examples/pagination' ,
46
46
'examples/search' ,
47
47
'examples/sorting' ,
48
+ 'examples/resizable' ,
48
49
'examples/loading-state' ,
49
50
'examples/wide-table' ,
50
51
'examples/fixed-header' ,
You can’t perform that action at this time.
0 commit comments