【发布时间】:2020-09-05 12:23:39
【问题描述】:
我有一个在剑道网格中分组的功能,我想在页面加载时调用它
componentDidMount() {
this.getDeductionInfosList();
this.state= this.createAppState({
group: [{ field: "DeductionTypeTitle" }], true)
}
getDeductionInfosList(data) {
GetRestrictionListService.getDeductionInfos( data,this.successGetDeductionInfos);
}
successGetDeductionInfos = (response) => {
if (response.Result) {
this.setState({
items: response.Result,
});
}
};
createAppState(dataState, collapseAll) {
const dataResult = process( this.state.items, dataState);
console.log(this.state.items)
if (collapseAll) {
dataResult.data.forEach(dataItem => dataItem.expanded = false);
}
this.setState({
dataResult: dataResult,
dataState: dataState
}) ;
}
但是当我在componentDidMount中使用时返回item空数组如何先从Api获取数据然后调用this.createAppState函数
【问题讨论】:
标签: javascript reactjs kendo-grid