React-data-grid выдает предупреждение при использовании Basic DropDownEditor
Вот версии, которые я использую для реагирования-сетки данных. Запуск приложения на Chrome.
"react": "^15.4.2",
"react-data-grid": "^2.0.8",
"react-data-grid-addons": "^2.0.17",
Я копирую пример Build-In-Editors с основного сайта. Сама сетка работает должным образом, но я получаю следующие предупреждения в консоли Chrome:
Warning: Failed prop type: Invalid prop `options[0]` supplied to `DropDownEditor`.
in DropDownEditor (created by HomePage)
in HomePage (created by RouterContext)
in div (created by App)
in App (created by RouterContext)
in RouterContext (created by Router)
in Router
Warning: Failed prop type: The prop `value` is marked as required in `DropDownFormatter`, but its value is `undefined`.
in DropDownFormatter (created by HomePage)
in HomePage (created by RouterContext)
in div (created by App)
in App (created by RouterContext)
in RouterContext (created by Router)
in Router
Вот фрагмент кода, который устанавливает код для компонента React Data Grid:
Импорт:
import {Editors, Formatters} from 'react-data-grid-addons';
const { DropDownEditor } = Editors;
const { DropDownFormatter } = Formatters;
Настройка параметров:
const titleTypes = [
{ id: 'bug', value: 'bug', text: 'Bug', title: 'Bug' },
{ id: 'improvement', value: 'improvement', text: 'Improvement', title: 'Improvement' },
{ id: 'epic', value: 'epic', text: 'Epic', title: 'Epic' },
{ id: 'story', value: 'story', text: 'Story', title: 'Story' }
];
const TitleTypesEditor = <DropDownEditor options={titleTypes}/>;
const TitleTypesFormatter = <DropDownFormatter options={titleTypes}/>;
this.state = {
columns: [{key: 'id', name: 'ID'}, {key: 'title', name: 'Title',
editable: true, editor: TitleTypesEditor, formatter: TitleTypesFormatter}],
rows: [{id:1, title: 'title1'}, {id:2, title: 'bug'}]
};
Рендеринг компонента...
<ReactDataGrid
columns={this.state.columns}
rowsCount={this.state.rows.length}
rowHeight={50}
minHeight={200}
rowGetter={this.rowGetter}
enableCellSelect={true}
onGridRowsUpdated={this.handleGridRowsUpdated}
/>
1 ответ
Пытаться Editors.AutoComplete
вместо DropDownEditor
а также DropDownFormatter
,
import {Editors} from 'react-data-grid-addons';
const TitleTypesEditor = <Editors.AutoComplete options={titleTypes}/>;
const TitleTypesFormatter = <Editors.AutoComplete options={titleTypes}/>;