diff --git a/packages/react-bootstrap-table2-editor/README.md b/packages/react-bootstrap-table2-editor/README.md
index b4e6b99..cda2e0a 100644
--- a/packages/react-bootstrap-table2-editor/README.md
+++ b/packages/react-bootstrap-table2-editor/README.md
@@ -140,7 +140,7 @@ const columns = [
text: 'Job Type',
editor: {
type: Type.SELECT,
- getOptions: () => [.....]
+ getOptions: (setOptions, { row, column }) => [.....]
}
}];
@@ -152,7 +152,7 @@ const columns = [
text: 'Job Type',
editor: {
type: Type.SELECT,
- getOptions: (setOptions) => {
+ getOptions: (setOptions, { row, column }) => {
setTimeout(() => setOptions([...]), 1500);
}
}
diff --git a/packages/react-bootstrap-table2-editor/src/dropdown-editor.js b/packages/react-bootstrap-table2-editor/src/dropdown-editor.js
index a54bc4d..b019e2e 100644
--- a/packages/react-bootstrap-table2-editor/src/dropdown-editor.js
+++ b/packages/react-bootstrap-table2-editor/src/dropdown-editor.js
@@ -8,7 +8,13 @@ class DropDownEditor extends Component {
super(props);
let options = props.options;
if (props.getOptions) {
- options = props.getOptions(this.setOptions.bind(this)) || [];
+ options = props.getOptions(
+ this.setOptions.bind(this),
+ {
+ row: props.row,
+ column: props.column
+ }
+ ) || [];
}
this.state = { options };
}
@@ -54,6 +60,8 @@ class DropDownEditor extends Component {
}
DropDownEditor.propTypes = {
+ row: PropTypes.object.isRequired,
+ column: PropTypes.object.isRequired,
defaultValue: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
diff --git a/packages/react-bootstrap-table2-editor/src/editing-cell.js b/packages/react-bootstrap-table2-editor/src/editing-cell.js
index 7c693b1..2a0d85b 100644
--- a/packages/react-bootstrap-table2-editor/src/editing-cell.js
+++ b/packages/react-bootstrap-table2-editor/src/editing-cell.js
@@ -201,7 +201,7 @@ export default (_, onStartEdit) =>
if (_.isFunction(column.editorRenderer)) {
editor = column.editorRenderer(editorProps, value, row, column, rowIndex, columnIndex);
} else if (isDefaultEditorDefined && column.editor.type === EDITTYPE.SELECT) {
- editor = ;
+ editor = ;
} else if (isDefaultEditorDefined && column.editor.type === EDITTYPE.TEXTAREA) {
editor = ;
} else if (isDefaultEditorDefined && column.editor.type === EDITTYPE.CHECKBOX) {
diff --git a/packages/react-bootstrap-table2-example/examples/cell-edit/dropdown-editor-with-dynamic-options-table.js b/packages/react-bootstrap-table2-example/examples/cell-edit/dropdown-editor-with-dynamic-options-table.js
index 715346b..02c822b 100644
--- a/packages/react-bootstrap-table2-example/examples/cell-edit/dropdown-editor-with-dynamic-options-table.js
+++ b/packages/react-bootstrap-table2-example/examples/cell-edit/dropdown-editor-with-dynamic-options-table.js
@@ -1,3 +1,4 @@
+/* eslint no-console: 0 */
/* eslint react/prefer-stateless-function: 0 */
import React from 'react';
@@ -25,22 +26,26 @@ const columns = [{
text: 'Job Type1',
editor: {
type: Type.SELECT,
- getOptions: () => [{
- value: 'A',
- label: 'A'
- }, {
- value: 'B',
- label: 'B'
- }, {
- value: 'C',
- label: 'C'
- }, {
- value: 'D',
- label: 'D'
- }, {
- value: 'E',
- label: 'E'
- }]
+ getOptions: (setOptions, { row, column }) => {
+ console.log(`current editing row id: ${row.id}`);
+ console.log(`current editing column: ${column.dataField}`);
+ return [{
+ value: 'A',
+ label: 'A'
+ }, {
+ value: 'B',
+ label: 'B'
+ }, {
+ value: 'C',
+ label: 'C'
+ }, {
+ value: 'D',
+ label: 'D'
+ }, {
+ value: 'E',
+ label: 'E'
+ }];
+ }
}
}, {
dataField: 'type2',
@@ -88,22 +93,26 @@ const columns = [{
text: 'Job Type1',
editor: {
type: Type.SELECT,
- getOptions: () => [{
- value: 'A',
- label: 'A'
- }, {
- value: 'B',
- label: 'B'
- }, {
- value: 'C',
- label: 'C'
- }, {
- value: 'D',
- label: 'D'
- }, {
- value: 'E',
- label: 'E'
- }]
+ getOptions: (setOptions, { row, column }) => {
+ console.log(\`current editing row id: $\{row.id}\`);
+ console.log(\`current editing column: $\{column.dataField}\`);
+ return [{
+ value: 'A',
+ label: 'A'
+ }, {
+ value: 'B',
+ label: 'B'
+ }, {
+ value: 'C',
+ label: 'C'
+ }, {
+ value: 'D',
+ label: 'D'
+ }, {
+ value: 'E',
+ label: 'E'
+ }];
+ }
}
}, {
dataField: 'type2',