@@ -135,24 +135,156 @@ and `direction` parameters respectively.
135
135
136
136
### Pagination
137
137
138
- TODO
138
+ Making pagination work with React Dynamic Data Table requires three extra
139
+ props. These are the ` currentPage ` , ` totalPages ` and ` changePage ` props. Once
140
+ these props are set correctly, a Bootstrap style pagination will be displayed
141
+ below the table.
142
+
143
+ The ` currentPage ` prop expects an integer representing the current page number
144
+ (one or above).
145
+
146
+ The ` totalPages ` prop expects an integer representing the total number of
147
+ pages in the data set (one or above). Pagination will only be shown if the
148
+ total number of pages is greater than one.
149
+
150
+ The ` changePage ` props expect a callable with a ` page ` argument, indicating the
151
+ new page number to load. This callable should:
152
+
153
+ 1 . Load a new page of data into the ` rows ` prop based on the passed ` page `
154
+ argument.
155
+ 2 . Set the ` currentPage ` prop to be equal to the passed ` page ` argument.
156
+
157
+ A example of this is shown below:
158
+
159
+ ``` JSX
160
+ // this.state.currentPage = 1;
161
+ // this.state.totalPages = 5;
162
+
163
+ < DynamicDataTable
164
+ rows= {this .state .users }
165
+ currentPage= {this .state .currentPage }
166
+ totalPages= {this .state .totalPages }
167
+ changePage= {page => this .changePage (page)}
168
+ / >
169
+ ```
170
+
171
+ ``` JSX
172
+ changePage (page ) {
173
+ const users = /* Get page of data from API endpoint */
174
+ this .setState ({ users: users, currentPage: page });
175
+ }
176
+ ```
139
177
140
178
### Row buttons
141
179
142
- TODO
180
+ Row buttons appear on the right hand side of every row in the React Dynamic Data
181
+ Table. By default, a 'View' button is provided, which simply links the user to
182
+ the current URL with the row's ` id ` appended.
183
+
184
+ You can completely override the row buttons that are displayed by provided a
185
+ ` buttons ` prop. This prop expects an array of objects, each containing a ` name `
186
+ and ` callback ` .
187
+
188
+ The ` name ` is string, such as 'View', 'Edit', 'Delete', etc.
189
+
190
+ The ` callback ` is a callable with a single argument. The argument will
191
+ contain an object representing the data of the row on which the button is
192
+ situated.
193
+
194
+ An example of setting custom row buttons is shown below.
195
+
196
+ ``` JSX
197
+ < DynamicDataTable
198
+ rows= {this .state .users }
199
+ buttons= {[
200
+ {
201
+ name: ' Edit' ,
202
+ callback : (user ) => {
203
+ // Show edit user view...
204
+ }
205
+ },
206
+ {
207
+ name: ' Delete' ,
208
+ callback : (user ) => {
209
+ // Delete user...
210
+ }
211
+ }
212
+ ]}
213
+ / >
214
+ ```
143
215
144
216
### Bulk select checkboxes
145
217
146
- TODO
218
+ If you wish to allow users to bulk select users in a React Dynamic Data Table,
219
+ you can specify the ` renderCheckboxes ` prop. This will render a series of
220
+ checkboxes against each row, on the left side of the table.
221
+
222
+ ``` JSX
223
+ < DynamicDataTable
224
+ rows= {this .state .users }
225
+ renderCheckboxes
226
+ / >
227
+ ```
228
+
229
+ Bulk select checkboxes are usually combined with bulk actions to perform
230
+ actions on one or more rows at once.
147
231
148
232
### Bulk actions
149
233
150
- TODO
234
+ Bulk actions, when combined with bulk select checkboxes allow you perform
235
+ actions of multiple rows at once. When in use, a menu will be rendered
236
+ in the top right of the table allowing your users to choose a bulk action
237
+ that will be applied to the selected rows.
238
+
239
+ To use bulk actions in your React Dynamic Data Table, you must specify the
240
+ ` actions ` props. This prop expects an array of objects, each containing a ` name `
241
+ and ` callback ` .
242
+
243
+ The ` name ` is string, such as 'Delete user(s)', 'Duplicate user(s)' etc.
244
+
245
+ The ` callback ` is a callable with a single argument. The argument will
246
+ contain an array of ` id ` properties, from all selected rows.
247
+
248
+ An example of show to use bulk actions is shown below.
249
+
250
+ ``` JSX
251
+ < DynamicDataTable
252
+ rows= {this .state .users }
253
+ renderCheckboxes
254
+ actions= {[
255
+ {
256
+ name: ' Delete user(s)' ,
257
+ callback : (ids ) => {
258
+ // Delete users...
259
+ },
260
+ },
261
+ ]}
262
+ / >
263
+ ```
151
264
152
265
### Loading message & indicator
153
266
154
- TODO
267
+ By default, the React Dynamic Data Table will not show indication that it is
268
+ loading. On slow connections, this may make the table appear unresponsive or
269
+ sluggish when initialing loading, changing pages, re-ordering, and so on.
270
+
271
+ If you wish you can specify a ` loadingMessage ` prop when you are loading in
272
+ your data, or performing other operations. This prop expects a string, which
273
+ should contain a message when loading, such as ` Loading... ` . When loading is
274
+ completed, this prop must be reset to an empty string in order to ensure
275
+ the data table is displayed.
276
+
277
+ Optionally, you can specify a ` loadingComponent ` prop. Whenever the
278
+ ` loadingMessage ` prop is specified, the component passed into the
279
+ ` loadingComponent ` prop will be rendered above it.
155
280
156
281
### Error message
157
282
158
- TODO
283
+ In the case that something goes wrong, such as data failing to load, you
284
+ can display and error message in place of the normal React Dynamic
285
+ Data Table output.
286
+
287
+ In order to display an error message, you just need to set the optional
288
+ ` errorMessage ` prop. This prop expects a string such as `An error has occurred
289
+ while loading user data.`. If the error is resolved, this prop must be reset
290
+ to an empty string in order to ensure the data table is displayed.
0 commit comments