React Bootstrap表1按字母顺序排序

发布于 2025-02-07 04:20:27 字数 1172 浏览 2 评论 0原文

对于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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小矜持 2025-02-14 04:20:27

使用下面的代码排序

defaultSortName: 'resellerName', 
defaultSortOrder: 'asc'

Use the code below to sort

defaultSortName: 'resellerName', 
defaultSortOrder: 'asc'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文