[英]React Pivot Table not rendering on change in state
I am new to react js and I am trying to create a pivot table using React Pivot table.我是反应 js 的新手,我正在尝试使用 React Pivot 表创建 pivot 表。 I want to be able to select a data set using a select drop down menu and update the state and re render the full table whenever there is a change in the drop down selection just like the jquery example shown here https://pivottable.js.org/examples/rcsvs.html
I want to be able to select a data set using a select drop down menu and update the state and re render the full table whenever there is a change in the drop down selection just like the jquery example shown here https://pivottable.js .org/examples/rcsvs.html
It works before I make any selections or changes to the Pivot Table.在我对 Pivot 表进行任何选择或更改之前,它就可以工作。 I am able to toggle between the 2 datasets and the state changes in the Pivot table.
我能够在 2 个数据集和 Pivot 表中的 state 更改之间切换。 But when I select a pivot dimension and use the pivot table, after that point, changing the select menu does not help me change the pivot table's state.
But when I select a pivot dimension and use the pivot table, after that point, changing the select menu does not help me change the pivot table's state. Please help.
请帮忙。
I tried following solution what was given in this question, but i wasnt abl to implement the second step as i dont know how to define that in component call.我尝试遵循这个问题中给出的解决方案,但我无法实现第二步,因为我不知道如何在组件调用中定义它。
How do I re render the entire React Pivot Table UI component when I change the selection in select tag? 当我更改 select 标记中的选择时,如何重新渲染整个 React Pivot 表 UI 组件?
const PlotlyRenderers = createPlotlyRenderers(Plot);
class PivotTablePlotly extends React.Component {
constructor(props) {
super(props);
this.state ={
rowData: [],
}
}
componentWillReceiveProps(nextProps) {
fetch(
"API Call"
)
.then((result) => result.json())
.then((rowData) => this.setState({ rowData }));
}
componentDidMount() {
fetch(
"API Call"
)
.then((result) => result.json())
.then((rowData) => this.setState({ rowData }));
}
renderTable() {
return (
<PivotTableUI
data={this.state.rowData}
onChange={s => this.setState(s)}
renderers={Object.assign({}, TableRenderers, PlotlyRenderers)}
{...this.state}
/>
)
}
render() {
return (
<div className="pivotTheme">
<Col>
<br />
{this.renderTable()}
</Col>
</div>
);
}
}
export default PivotTablePlotly;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.