我有这种情况:How to create a sortable table in React? How to access class method from the sorted objects?
但是我的表只是另一个组件中数据的包装器。所有datatoSort位于另一个组件中。并导入并使用modalWindow组件。当我单击anotherComponent中的选择项目按钮时,元素表就会出现在模式窗口中。如何对这些数据进行排序,如何获取它们?我无法在模式窗口内实现表列的排序。
<ExtendedModalBar
list={this.state.modalList}
onCancel={this.handleExtendedModalClose}
onSave={(...args) => this.handleSaveFromModal(...args)}
selectedItems={this.state.modalItems}
show={this.state.showExtendedModal}
type={this.state.modalType}
//onClick={this.onSort('', )}
/>
showExtendedModal = type => {
switch (type) {
case 'devices':
this.setState({
showExtendedModal: true,
modalType: type,
modalList: this.props.devices.list,
modalItems: this.state.devices
});
break;
case 'tariffs':
this.setState({
showExtendedModal: true,
modalType: type,
modalList: this.state.tariffList,
modalItems: this.state.tariffs
});
break;
case 'autoconfirms':
...