diff --git a/packages/react-bootstrap-table2-editor/src/checkbox-editor.js b/packages/react-bootstrap-table2-editor/src/checkbox-editor.js index 561f25c..51dd12b 100644 --- a/packages/react-bootstrap-table2-editor/src/checkbox-editor.js +++ b/packages/react-bootstrap-table2-editor/src/checkbox-editor.js @@ -13,7 +13,9 @@ class CheckBoxEditor extends Component { } componentDidMount() { + const { didMount } = this.props; this.checkbox.focus(); + if (didMount) didMount(); } getValue() { @@ -28,7 +30,7 @@ class CheckBoxEditor extends Component { } render() { - const { defaultValue, className, ...rest } = this.props; + const { defaultValue, didMount, className, ...rest } = this.props; const editorClass = cs('editor edit-chseckbox checkbox', className); return ( +export default (_, onStartEdit) => class EditingCell extends Component { static propTypes = { row: PropTypes.object.isRequired, @@ -151,6 +151,10 @@ export default _ => onBlur: this.handleBlur }; + if (onStartEdit) { + editorProps.didMount = () => onStartEdit(row, column, rowIndex, columnIndex); + } + const isDefaultEditorDefined = _.isObject(column.editor); if (isDefaultEditorDefined) { diff --git a/packages/react-bootstrap-table2-editor/src/text-editor.js b/packages/react-bootstrap-table2-editor/src/text-editor.js index b44c2da..1a28a29 100644 --- a/packages/react-bootstrap-table2-editor/src/text-editor.js +++ b/packages/react-bootstrap-table2-editor/src/text-editor.js @@ -5,9 +5,10 @@ import PropTypes from 'prop-types'; class TextEditor extends Component { componentDidMount() { - const { defaultValue } = this.props; + const { defaultValue, didMount } = this.props; this.text.value = defaultValue; this.text.focus(); + if (didMount) didMount(); } getValue() { @@ -15,7 +16,7 @@ class TextEditor extends Component { } render() { - const { defaultValue, className, ...rest } = this.props; + const { defaultValue, didMount, className, ...rest } = this.props; const editorClass = cs('form-control editor edit-text', className); return ( { console.log('start to edit!!!'); }, beforeSaveCell: (oldValue, newValue, row, column) => { console.log('Before Saving Cell!!'); }, afterSaveCell: (oldValue, newValue, row, column) => { console.log('After Saving Cell!!'); } }) } @@ -55,6 +56,7 @@ export default () => ( columns={ columns } cellEdit={ cellEditFactory({ mode: 'click', + onStartEdit: (row, column, rowIndex, columnIndex) => { console.log('Start to edit!!!'); }, beforeSaveCell: (oldValue, newValue, row, column) => { console.log('Before Saving Cell!!'); }, afterSaveCell: (oldValue, newValue, row, column) => { console.log('After Saving Cell!!'); } }) }