简体   繁体   中英

React Bootstrap Table 1 Default Sorting by Alphabetical Order

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/>
    );
}

Use the code below to sort

defaultSortName: 'resellerName', 
defaultSortOrder: 'asc'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM