Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to sort react-bootstrap Table component

I'm new to React and am using the Table component from react-bootstrap.

I want to sort my table in ascending order of the 'Days Till Expiry' column. My React App

But the Table component doesn't have a sorting property, does anyone know how I could do this?

like image 979
tnoel999888 Avatar asked Apr 09 '18 14:04

tnoel999888


People also ask

How do you sort a table in react?

Sorting the React table data. Now, whenever we click any of the table headers, we can sort that particular column in ascending or descending order. To achieve this, we must use an ordering function that knows how to collate and order items. In this case, we will use the sort() function.

How do I sort a table column in bootstrap?

The sort table needed a bootstrap table with a JavaScript method. There is two ways to sort table data which is below. The first way helps to sort table data automatically using the DataTable() method. The second way helps the user to sort table data as per requirement.

How do you sort a functional component in react JS?

The sort() method will sort elements based on the return value of the compare() function with the following rules: If compare(a,b) is less than zero, the sort() method sorts a to a lower index than b . If compare(a,b) is greater than zero, the sort() method sort b to a lower index than a , i.e., b will come first.


1 Answers

I would recommend using react-bootstrap-table then use these examples

like image 126
Paul McLoughlin Avatar answered Sep 23 '22 22:09

Paul McLoughlin