Skip to content

Commit 62b928a

Browse files
author
Yakir Green
committed
Dynamic options list in Editable select column AllenFang#1423
Still missing support for insert dialog.
1 parent 4ec5e95 commit 62b928a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Editor.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22

3-
const editor = function(editable, attr, format, editorClass, defaultValue, ignoreEditable) {
3+
const editor = function(editable, attr, format, editorClass, defaultValue, ignoreEditable, row) {
44
if (editable === true ||
55
(editable === false && ignoreEditable) ||
66
typeof editable === 'string') { // simple declare
@@ -50,7 +50,10 @@ const editor = function(editable, attr, format, editorClass, defaultValue, ignor
5050
return (
5151
<option key={ 'option' + i } value={ value }>{ text }</option>
5252
);
53-
});
53+
}
54+
);
55+
} else if (values && typeof values === 'function') {
56+
options = values(row);
5457
}
5558
return (
5659
<select { ...attr } defaultValue={ defaultValue }>

src/TableEditColumn.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ class TableEditColumn extends Component {
191191
};
192192
cellEditor = customEditor.getElement(this.handleCustomUpdate, customEditorProps);
193193
} else {
194-
cellEditor = editor(editable, attr, format, editorClass, this.valueShortCircuit(fieldValue));
194+
cellEditor = editor(editable, attr, format, editorClass, this.valueShortCircuit(fieldValue),
195+
null, row);
195196
}
196197

197198
if (isFocus) {

0 commit comments

Comments
 (0)