diff --git a/docs/cell-edit-props.md b/docs/cell-edit-props.md index cae2ca8..d71761f 100644 --- a/docs/cell-edit-props.md +++ b/docs/cell-edit-props.md @@ -59,6 +59,24 @@ const cellEdit = { } ``` +If you want to perform a async `beforeSaveCell`, you can do it like that: + +```js +const cellEdit: { + // omit... + beforeSaveCell(oldValue, newValue, row, column, done) { + setTimeout(() => { + if (confirm('Do you want to accep this change?')) { + done(); // contine to save the changes + } else { + done(false); // reject the changes + } + }, 0); + return { async: true }; + } +}; +``` + ## cellEdit.afterSaveCell - [Function] This callback function will be called after updating cell. diff --git a/docs/column-props.md b/docs/column-props.md index 08e4164..4b15d26 100644 --- a/docs/column-props.md +++ b/docs/column-props.md @@ -365,17 +365,27 @@ A new `String` will be the result of element headerAlign. ## column.events - [Object] -You can assign any [HTML Event](https://www.w3schools.com/tags/ref_eventattributes.asp) on table column via event property: +You can assign any [HTML Event](https://www.w3schools.com/tags/ref_eventattributes.asp) on table column via `events` property. + +`react-bootstrap-table2` currently only support following events which will receive some specific information: + +* onClick +* onDoubleClick +* onMouseEnter +* onMouseLeave +* onContextMenu ```js { // omit... events: { - onClick: e => { ... } + onClick: (e, column, columnIndex, row, rowIndex) => { ... }, } } ``` +If the events is not listed above, the callback function will only receive the `event` object. + ## column.headerEvents - [Object] `headerEvents` same as [`column.events`](#columnevents-object) but this is for header column. @@ -528,6 +538,27 @@ The return value can be a bool or an object. If your validation is pass, return } ``` +If you want to perform a asycn validation, you can do it like this: +```js +{ + // omit... + validator: (newValue, row, column, done) => { + settimeout(() => { + // async validation ok + return done(); + + // async validation not ok + return done({ + valid: false, + message: 'SOME_REASON_HERE' + }); + + }, 2000); + return { async: true }; + } +} +``` + ## column.editCellStyle - [Object | Function] You can use `column.editCellStyle` to custom the style of `