Skip to content

Commit eaf1aca

Browse files
committed
fix dropdown
1 parent 2ffdd59 commit eaf1aca

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/components/Cell.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default class Cell extends React.Component {
1414
<select className="form-control"
1515
data-column={data.columnIndex}
1616
data-row={data.rowIndex}
17+
data-select={JSON.stringify(value.items)}
1718
onChange={onEdit}
1819
value={value.selected}>
1920
{value.items.map((item, i) => <option key={i}>{item}</option>)}

src/pages/Index.jsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,15 @@ export default class Index extends Component {
6767

6868
const {dataSource} = this.state
6969

70-
dataSource[rowIndex][columnIndex] = fieldValue;
70+
if (target.dataset.select) {
71+
dataSource[rowIndex][columnIndex] = {
72+
selected: fieldValue,
73+
items: JSON.parse(target.dataset.select)
74+
}
75+
} else {
76+
dataSource[rowIndex][columnIndex] = fieldValue;
77+
}
78+
7179

7280
this.setState({dataSource})
7381
}

0 commit comments

Comments
 (0)