Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0e2862b

Browse files
Merge pull request #523 from react-bootstrap-table/enhance/514
Enhance/514
2 parents 591abaa + 5ac058c commit 0e2862b

File tree

8 files changed

+44
-21
lines changed

8 files changed

+44
-21
lines changed

‎packages/react-bootstrap-table2-editor/src/checkbox-editor.js‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ class CheckBoxEditor extends Component {
1313
}
1414

1515
componentDidMount() {
16+
const { didMount } = this.props;
1617
this.checkbox.focus();
18+
if (didMount) didMount();
1719
}
1820

1921
getValue() {
@@ -28,7 +30,7 @@ class CheckBoxEditor extends Component {
2830
}
2931

3032
render() {
31-
const { defaultValue, className, ...rest } = this.props;
33+
const { defaultValue, didMount,className, ...rest } = this.props;
3234
const editorClass = cs('editor edit-chseckbox checkbox', className);
3335
return (
3436
<input
@@ -50,12 +52,14 @@ CheckBoxEditor.propTypes = {
5052
]),
5153
value: PropTypes.string,
5254
defaultValue: PropTypes.any,
53-
onChange: PropTypes.func
55+
onChange: PropTypes.func,
56+
didMount: PropTypes.func
5457
};
5558
CheckBoxEditor.defaultProps = {
5659
className: '',
5760
value: 'on:off',
5861
defaultValue: false,
59-
onChange: undefined
62+
onChange: undefined,
63+
didMount: undefined
6064
};
6165
export default CheckBoxEditor;

‎packages/react-bootstrap-table2-editor/src/context.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default (
2323
blurToSave: PropTypes.bool,
2424
beforeSaveCell: PropTypes.func,
2525
afterSaveCell: PropTypes.func,
26+
onStartEdit: PropTypes.func,
2627
nonEditableRows: PropTypes.func,
2728
timeToCloseMessage: PropTypes.number,
2829
errorMessage: PropTypes.any
@@ -31,7 +32,7 @@ export default (
3132

3233
constructor(props) {
3334
super(props);
34-
EditingCell = props.cellEdit.editingCellFactory(_);
35+
EditingCell = props.cellEdit.editingCellFactory(_,props.cellEdit.options.onStartEdit);
3536
this.startEditing = this.startEditing.bind(this);
3637
this.escapeEditing = this.escapeEditing.bind(this);
3738
this.completeEditing = this.completeEditing.bind(this);

‎packages/react-bootstrap-table2-editor/src/date-editor.js‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ import PropTypes from 'prop-types';
55

66
class DateEditor extends Component {
77
componentDidMount() {
8-
const { defaultValue } = this.props;
8+
const { defaultValue, didMount } = this.props;
99
this.date.valueAsDate = new Date(defaultValue);
1010
this.date.focus();
11+
if (didMount) didMount();
1112
}
1213

1314
getValue() {
1415
return this.date.value;
1516
}
1617

1718
render() {
18-
const { defaultValue, className, ...rest } = this.props;
19+
const { defaultValue, didMount,className, ...rest } = this.props;
1920
const editorClass = cs('form-control editor edit-date', className);
2021
return (
2122
<input
@@ -33,10 +34,12 @@ DateEditor.propTypes = {
3334
PropTypes.string,
3435
PropTypes.object
3536
]),
36-
defaultValue: PropTypes.string
37+
defaultValue: PropTypes.string,
38+
didMount: PropTypes.func
3739
};
3840
DateEditor.defaultProps = {
3941
className: '',
40-
defaultValue: ''
42+
defaultValue: '',
43+
didMount: undefined
4144
};
4245
export default DateEditor;

‎packages/react-bootstrap-table2-editor/src/dropdown-editor.js‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ import PropTypes from 'prop-types';
55

66
class DropDownEditor extends Component {
77
componentDidMount() {
8-
const { defaultValue } = this.props;
8+
const { defaultValue, didMount } = this.props;
99
this.select.value = defaultValue;
1010
this.select.focus();
11+
if (didMount) didMount();
1112
}
1213

1314
getValue() {
1415
return this.select.value;
1516
}
1617

1718
render() {
18-
const { defaultValue, className, options, ...rest } = this.props;
19+
const { defaultValue, didMount,className, options, ...rest } = this.props;
1920
const editorClass = cs('form-control editor edit-select', className);
2021

2122
const attr = {
@@ -51,11 +52,13 @@ DropDownEditor.propTypes = {
5152
label: PropTypes.string,
5253
value: PropTypes.any
5354
}))
54-
]).isRequired
55+
]).isRequired,
56+
didMount: PropTypes.func
5557
};
5658
DropDownEditor.defaultProps = {
5759
className: '',
5860
defaultValue: '',
59-
style: {}
61+
style: {},
62+
didMount: undefined
6063
};
6164
export default DropDownEditor;

‎packages/react-bootstrap-table2-editor/src/editing-cell.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import TextEditor from './text-editor';
1414
import EditorIndicator from './editor-indicator';
1515
import { TIME_TO_CLOSE_MESSAGE, EDITTYPE } from './const';
1616

17-
export default _ =>
17+
export default (_,onStartEdit) =>
1818
class EditingCell extends Component {
1919
static propTypes = {
2020
row: PropTypes.object.isRequired,
@@ -151,6 +151,10 @@ export default _ =>
151151
onBlur: this.handleBlur
152152
};
153153

154+
if (onStartEdit) {
155+
editorProps.didMount = () => onStartEdit(row, column, rowIndex, columnIndex);
156+
}
157+
154158
const isDefaultEditorDefined = _.isObject(column.editor);
155159

156160
if (isDefaultEditorDefined) {

‎packages/react-bootstrap-table2-editor/src/text-editor.js‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ import PropTypes from 'prop-types';
55

66
class TextEditor extends Component {
77
componentDidMount() {
8-
const { defaultValue } = this.props;
8+
const { defaultValue, didMount } = this.props;
99
this.text.value = defaultValue;
1010
this.text.focus();
11+
if (didMount) didMount();
1112
}
1213

1314
getValue() {
1415
return this.text.value;
1516
}
1617

1718
render() {
18-
const { defaultValue, className, ...rest } = this.props;
19+
const { defaultValue, didMount,className, ...rest } = this.props;
1920
const editorClass = cs('form-control editor edit-text', className);
2021
return (
2122
<input
@@ -36,10 +37,12 @@ TextEditor.propTypes = {
3637
defaultValue: PropTypes.oneOfType([
3738
PropTypes.string,
3839
PropTypes.number
39-
])
40+
]),
41+
didMount: PropTypes.func
4042
};
4143
TextEditor.defaultProps = {
4244
className: null,
43-
defaultValue: ''
45+
defaultValue: '',
46+
didMount: undefined
4447
};
4548
export default TextEditor;

‎packages/react-bootstrap-table2-editor/src/textarea-editor.js‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ class TextAreaEditor extends Component {
1010
}
1111

1212
componentDidMount() {
13-
const { defaultValue } = this.props;
13+
const { defaultValue, didMount } = this.props;
1414
this.text.value = defaultValue;
1515
this.text.focus();
16+
if (didMount) didMount();
1617
}
1718

1819
getValue() {
@@ -27,7 +28,7 @@ class TextAreaEditor extends Component {
2728
}
2829

2930
render() {
30-
const { defaultValue, className, ...rest } = this.props;
31+
const { defaultValue, didMount,className, ...rest } = this.props;
3132
const editorClass = cs('form-control editor edit-textarea', className);
3233
return (
3334
<textarea
@@ -50,11 +51,13 @@ TextAreaEditor.propTypes = {
5051
PropTypes.string,
5152
PropTypes.number
5253
]),
53-
onKeyDown: PropTypes.func
54+
onKeyDown: PropTypes.func,
55+
didMount: PropTypes.func
5456
};
5557
TextAreaEditor.defaultProps = {
5658
className: '',
5759
defaultValue: '',
58-
onKeyDown: undefined
60+
onKeyDown: undefined,
61+
didMount: undefined
5962
};
6063
export default TextAreaEditor;

‎packages/react-bootstrap-table2-example/examples/cell-edit/cell-edit-hooks-table.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const columns = [{
4141
columns={ columns }
4242
cellEdit={ cellEditFactory({
4343
mode: 'click',
44+
onStartEdit: (row, column, rowIndex, columnIndex) => { console.log('start to edit!!!'); },
4445
beforeSaveCell: (oldValue, newValue, row, column) => { console.log('Before Saving Cell!!'); },
4546
afterSaveCell: (oldValue, newValue, row, column) => { console.log('After Saving Cell!!'); }
4647
}) }
@@ -55,6 +56,7 @@ export default () => (
5556
columns={ columns }
5657
cellEdit={ cellEditFactory({
5758
mode: 'click',
59+
onStartEdit: (row, column, rowIndex, columnIndex) => { console.log('Start to edit!!!'); },
5860
beforeSaveCell: (oldValue, newValue, row, column) => { console.log('Before Saving Cell!!'); },
5961
afterSaveCell: (oldValue, newValue, row, column) => { console.log('After Saving Cell!!'); }
6062
}) }

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /