You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
- Fix bug where filtering from a page > 1 could leave user on a
non-existant page
- Separate cssClass column def property into headerCssClass and
rowCssClass
- Update to React 0.14.1
- Update Readme.md
Copy file name to clipboardExpand all lines: README.md
+49-15Lines changed: 49 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,9 @@
1
1
# tabletable
2
2
3
-
## Reactjs Simple Table
3
+
## React Simple Table
4
+
tabletable is a simple table component written purely in React. It is the result of my frustrations with Griddle and other React tables that are overly prescriptive in how they must be used and make things very difficult to customize and integrate into complex applications.
4
5
5
-
tabletable is a simple table component written purely in ReactJS. It is the result of my frustrations with Griddle and other React tables that are overly prescriptive in how they must be used and make things very difficult to customize and integrate into complex applications.
6
-
7
-
tabletable takes any sort of data structure (provided it is Immutable) and allows you to define your columns' markup and data projections as you like. It is also server-side rendering friendly.
6
+
tabletable takes any sort of data structure and allows you to define your columns' markup and data projections as you like. It is also server-side rendering friendly.
8
7
9
8
tabletable has some limitations that I hope to address in the future:
10
9
- It requires an Immutablejs data structure for its data
@@ -14,29 +13,65 @@ tabletable has some limitations that I hope to address in the future:
14
13
If you are interested in helping with any of this, I would gladly take pull requests.
15
14
16
15
## Using it
17
-
18
16
To use tabletable:
19
17
- Install the component through NPM
20
18
- Require it
21
19
- Pass it an Immutablejs Sequence of rows, a column definition object, and an optional filter handler.
**rowsPerPage [number]** - number of rows to display per page.
31
+
32
+
**pagerSize [number]** - number pages to display in pager.
33
+
34
+
**showPager [bool]** - show/hide the pager.
35
+
36
+
**showFilter [bool]** - show/hide the filter input.
37
+
38
+
**pager [React.Component]** - pager component to use in place of default pager.
39
+
40
+
**onFilterAction [func(filterValue: string)]** - callback function for responding to filter input.
24
41
42
+
**filterValue [string]** - text to display in search filter.
43
+
44
+
### Column definition options
45
+
Column definitions are a flexible way to get some fairly complex behaviors into the table while also allowing the *shape* of the data to be however you prefer. Each column defines a function that receives the row data and index as arguments and returns a React component that displays the content. This means that you can drive complex behaviors from the state and props of the parent component. The properties available in the definition objects are:
46
+
47
+
#### Required
48
+
**data [func(row: object, index: number)]** - a function that transforms the row data into a React component to be displayed.
49
+
50
+
#### Optional
51
+
**display [string]** - Header value for column. If not defined, the property name for the column object will be used instead.
52
+
53
+
**headerCssClass [string]** - CSS class(es) to use for header column (th) element.
54
+
55
+
**rowCssClass [string]** - CSS class(es) to use for row column (td) element.
56
+
57
+
**visible [bool]** - show/hide the column.
58
+
59
+
### Contrived Example
25
60
let columnDefs = {
26
61
index: {
27
62
display: 'Index',
28
-
cssClass: 'col-sm-1',
63
+
headerCssClass: 'col-sm-1',
29
64
visible: true,
30
65
data: (row,index) => <div>{index}</div>,
31
66
},
32
67
name: {
33
68
display: 'Name',
34
-
cssClass: 'col-sm-10',
69
+
headerCssClass: 'col-sm-10',
35
70
data: row => <div>{row.get('name')}</div>,
36
71
},
37
72
timestamp: {
38
73
display: 'Created',
39
-
cssClass: 'col-sm-1',
74
+
headerCssClass: 'col-sm-1',
40
75
data: row => <div>{row.get('timestamp')}</div>,
41
76
},
42
77
};
@@ -77,7 +112,6 @@ You can also define a custom pager that will be substituted for the default page
77
112
The custom pager needs to behave similarly and accept the same props as the default pager. I suggest you copy src/Pager.jsx and modify to suit your needs.
0 commit comments