33[ Developed by Flipbyte] ( https://www.flipbyte.com/ )
44
55[ ![ npm package] [ npm-badge ]] [ npm ]
6+ [ ![ Codacy Badge] [ codacy-badge ]] [ codacy ]
67
78Datatable built using React and Redux to fetch JSON data asynchronously using REST API.
89
@@ -46,33 +47,30 @@ import { reducer, epics } from '@flipbyte/redux-datatable';
4647 name: ' your_table_name' , // this is the key used to set your table data inside the table reducer
4748 height: 500 ,
4849 rowHeight: 50 ,
49- pagination: {
50- items: [{
51- type: ' limiter' ,
52- visible: true ,
53- position: 10 ,
54- options: [10 , 20 , 50 , 200 , 2000 ],
55- default: 200 ,
56- style: {
57- right: false ,
58- }
59- }, {
60- type: ' pages' ,
61- visible: true ,
62- position: 20 ,
63- style: {
50+ pagination: {
51+ // visible: true, // or an object { top: true, bottom: false } default visible
52+ items: {
53+ limiter: {
54+ type: ' limiter' ,
55+ visible: true ,
56+ position: 10 ,
57+ options: [10 , 20 , 50 , 200 , 2000 ],
58+ default: 200 ,
59+ },
60+ pages: {
61+ type: ' pages' ,
62+ visible: true ,
63+ position: 20 ,
6464 right: true ,
65- }
66- }, {
67- type: ' resultCount' ,
68- visible: true ,
69- position: 30 ,
70- style: {
71- width: ' 350px' ,
72- textAlign: ' center' ,
73- }
74- }]
75- },
65+ },
66+ resultCount: {
67+ type: ' resultCount' ,
68+ visible: true ,
69+ position: 30 ,
70+ right: true ,
71+ },
72+ }
73+ },
7674 routes: { // You can add other routes and handle them using custom actions.
7775 get: { // The route used to fetch data and it's params
7876 route: ' /{your_route}' ,
@@ -95,9 +93,6 @@ import { reducer, epics } from '@flipbyte/redux-datatable';
9593 label: ' Columns' ,
9694 visible: true ,
9795 state: false ,
98- style: {
99- right: true
100- }
10196 },
10297 ...
10398 ]
@@ -199,29 +194,24 @@ const YourComponent = () =>
199194| routes | object | true | - | Routes definition to fetch data and other custom routes config for custom handling (Check below) |
200195| toolbar | array | false | [ ] | Toolbar definition (Check below) |
201196| columns | array | true | - | Columns to display |
197+ | styles | object | false | {} | Custom styles for your table |
202198
203199#### Pagination object
204200
205201| Key | Type | Required | Default | Description |
206202| ------------ | ------------ | ------------ | ------------ | ------------ |
207- | items | array | false | [ ] | Array of item objects available for display in the pagination bar. Check below for items available |
203+ | items | object | false | {} | Items available for display in the pagination bar. Check below for items available |
208204| visible | boolean/object | false | true | Whether the pagination is visible or not |
209205
210- ##### Pagination items array :
206+ ##### Pagination items object :
211207
212208| Key | Type | Required | Default | Description |
213209| ------------ | ------------ | ------------ | ------------ | ------------ |
214210| type | string | true | - | One of the following: limiter, pages, resultCount |
215211| visible | boolean | false | true | Whether the item is visible |
216- | style | object | false | {} | Stylable properties |
217212| ** Limiter specific options** | | | | |
218213| options | array | true | - | Array of integers with limiter options |
219214| default | array | true | - | One of the values in the limiter options key |
220- | ** - style** | | | | |
221- | right | boolean | false | false | Align the item to the right |
222- | width | integer | false | 200 | Width of the item |
223- | textAlign | string | false | left | Align the text of the item to the right, left or center|
224- | fontSize | string | false | 14 | The font size of the text in the item |
225215
226216#### Routes object
227217
@@ -244,18 +234,13 @@ Toolbar config is an array of array of object where objects are the toolbar item
244234| label | string | true | - | Label for the toolbar item |
245235| visible | boolean | false | true | Whether the item is visible |
246236| state | boolean | false | false | Whether to pass the state object as item prop |
247- | style | object | false | {} | Define toolbar item styles |
248237| ** For type: actions** | | | | |
249238| options | array | true | - | Array of option objects |
250239| ** -- options** | | | | |
251240| type | string | true | action | Available option: action |
252241| name | string | true | - | Unique name for the action |
253242| label | string | true | - | Label for the action |
254243| thunk | function | true | - | An action creator which is dispatched on action click. Check demo schema. |
255- | ** - styles** | | | | |
256- | right | boolean | false | false | Align the item to the right |
257- | width | integer | false | 200 | Width of the item |
258- | fontSize | string | false | 14 | The font size of the text in the item |
259244
260245#### Columns object
261246
@@ -276,8 +261,29 @@ Toolbar config is an array of array of object where objects are the toolbar item
276261| label | string | true | - | Label for the action |
277262| thunk | function | true | - | An action creator which is dispatched on action click. Check demo schema. |
278263
264+ #### Styles object
265+
266+ Styles has the following properties avaailable:
267+
268+ | Key | Type | Required | Default | Description |
269+ | ------------ | ------------ | ------------ | ------------ | ------------ |
270+ | tableContainer | styled-components style object | false | - | Outer table container |
271+ | table | styled-components style object | false | - | Table component |
272+ | thead | styled-components style object | false | - | Table header component |
273+ | tbody | styled-components style object | false | - | Table body component |
274+ | tr | object | false | - | Table rows - the object can contain the following keys ` header ` , ` filter ` , ` body ` , each of whose values is a styled-components style object| |
275+ | th | styled-components style object | false | - | Table header columns |
276+ | td | object | false | - | Table columns - the object contain the following keys ` filter ` , ` body ` whose value is a styled-components style object |
277+ | toolbar | object | false | - | Keys ` container ` and ` row ` which are styled-components style object and ` item ` which is an object with keys that are the names of the respective items (as defined in the config) and the value is a styled-components style object |
278+ | pagination | object | false | - | Keys ` container ` - a styled-components style object and ` item ` - same as above toolbar item |
279+ | filter | object | false | - | Each key is the name of the column and the value is the styled-components style object |
280+ | body | object | false | - | Same as ` filter ` (above) |
281+
279282## License
280283The MIT License (MIT)
281284
282285[ npm-badge ] : https://img.shields.io/npm/v/@flipbyte/redux-datatable.svg
283286[ npm ] : https://www.npmjs.com/package/@flipbyte/redux-datatable
287+
288+ [ codacy-badge ] : https://api.codacy.com/project/badge/Grade/67274650b4874f5db55ede76156ab4d2
289+ [ codacy ] : https://www.codacy.com/app/flipbyte/redux-datatable?utm_source=github.com& ; utm_medium=referral& ; utm_content=flipbyte/redux-datatable& ; utm_campaign=Badge_Grade
0 commit comments