React Bootstrap表1按字母顺序排序
对于React Bootstrap表,如何按字母顺序按默认情况下对名称列进行排序?现在,我只能通过单击“排序”图标来按字母顺序排序它
<BootstrapTable
data={this.props.resellerList}
tableHeaderClass='header_white'
options={options}
bordered={false}
insertRow={this.state.isAdmin}
pagination
exportCSV
csvFileName='Client_List.csv'
>
<TableHeaderColumn row='0' rowSpan='1' dataField='resellerName' dataSort isKey={true} dataAlign='center' filter={{ type: 'TextFilter', placeholder: ' ' }} caretRender={sortCaret} dataFormat={this.nameFormatter} csvHeader='Name'>Name</TableHeaderColumn>
</BootstrapTable>
export const sortCaret = (direction, fieldName) => {
if (direction === 'asc') {
return (
<SortAscendingIcon/>
);
}
if (direction === 'desc') {
return (
<SortDescendingIcon/>
);
}
return (
<SortIcon/>
);
}
For the react bootstrap table, how to sort the name column by default in alphabetical order? Now I can only sort it by alphabetical order by clicking the sort icon but I want the users to see the name in alphabetical order by default when they first open the page
<BootstrapTable
data={this.props.resellerList}
tableHeaderClass='header_white'
options={options}
bordered={false}
insertRow={this.state.isAdmin}
pagination
exportCSV
csvFileName='Client_List.csv'
>
<TableHeaderColumn row='0' rowSpan='1' dataField='resellerName' dataSort isKey={true} dataAlign='center' filter={{ type: 'TextFilter', placeholder: ' ' }} caretRender={sortCaret} dataFormat={this.nameFormatter} csvHeader='Name'>Name</TableHeaderColumn>
</BootstrapTable>
export const sortCaret = (direction, fieldName) => {
if (direction === 'asc') {
return (
<SortAscendingIcon/>
);
}
if (direction === 'desc') {
return (
<SortDescendingIcon/>
);
}
return (
<SortIcon/>
);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用下面的代码排序
Use the code below to sort