mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
fix #1027
This commit is contained in:
parent
423769c134
commit
856e63d524
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 = <DropdownEditor { ...editorProps } />;
|
||||
editor = <DropdownEditor { ...editorProps } row={ row } column={ column } />;
|
||||
} else if (isDefaultEditorDefined && column.editor.type === EDITTYPE.TEXTAREA) {
|
||||
editor = <TextAreaEditor { ...editorProps } autoSelectText={ autoSelectText } />;
|
||||
} else if (isDefaultEditorDefined && column.editor.type === EDITTYPE.CHECKBOX) {
|
||||
|
||||
@ -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',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user