Created
October 27, 2016 15:16
-
-
Save AllenFang/d8e69441dbafb357b410507ca7f2560a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function revertSortFunc(a, b, order) { // order is desc or asc | |
if (order === 'desc') { | |
return a.price - b.price; | |
} else { | |
return b.price - a.price; | |
} | |
} | |
class CustomSortTable extends React.Component { | |
render() { | |
return ( | |
<BootstrapTable data={ products }> | |
<TableHeaderColumn dataField='id' isKey>Product ID</TableHeaderColumn> | |
<TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn> | |
<TableHeaderColumn dataField='price' dataSort sortFunc={ revertSortFunc }>Product Price</TableHeaderColumn> | |
</BootstrapTable> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment