【发布时间】:2020-08-06 10:17:54
【问题描述】:
function TopicsTable(props) {
return (
<Table className="tablecss">
<thead>
<tr>
<th>
<button type="button">
{props.getHeader[0]}
</button>
</th>
<th>
<button type="button">
{props.getHeader[1]}
</button>
</th>
<th>
<button type="button">
{props.getHeader[2]}
</button>
</th>
<th>
<button type="button">
{props.getHeader[3]}
</button>
</th>
<th>
<button type="button">
{props.getHeader[4]}
</button>
</th>
<th>
<button type="button">
{props.getHeader[5]}
</button>
</th>
</tr>
</thead>
<TableBody>
{(props.getRowInfo)}
</TableBody>
</Table>
);
}
getRowsData = () => {
var rowContents = this.state.data;
return rowContents.map((rowContent, index) => {
this.state.rowCount = this.state.rowCount + 1;
return <React.Fragment><TableRow key={index} onClick={() => this.handleClick(index)}>{this.RenderCell(rowContent)}</TableRow> {this.state.show && this.state.id === index ? <ChildComponent/>:""} </React.Fragment>
})
}
render() {
return (
<div className="Main">
<header className="App-header">
<h2 className="hdr"><i>Openion</i></h2>
</header>
<h4><Actionunit /></h4>
<br />
<TopicsTable getHeader={this.getHeader()} getRowInfo={this.getRowsData()}/>
</div>
);
}
当我点击 reactjs 中的按钮时,按升序和降序对表格进行排序
【问题讨论】:
-
您可以发布您用于表格的数据格式吗?
-
"TableData": [ { "Tag": [ "Tag1", "Tag2" ], "Date": "03/02/2020", "Upvote": 2, "Downvote": 1、“评论”:4、“主题”:“你想在devcon上了解哪些主题?” }, { "Topic": "季度规划应该是什么样子?", "Tag": [ "Tag9" ], "Date": "03/12/2019", "Downvote": 2, "Comment": 12,“点赞”:30 },
标签: reactjs