I using bootstrap table and there is a default sorting of first column. How can I change default column and choose another and using (Ascending/Descending)
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.
Sort. Sorting allows the user to reorder rows by the contents of a column. This is a live continuous sort , and new rows that get added or rows that get edited will be resorted immediately after, and you will not be able to manually reorder rows. You can sort on multiple columns with multiple sort directions.
Adding the "sortable" class to a <table> element provides support for sorting by column value. Clicking the column headers will sort the table rows by that column's value. Tables must use <thead> and <th> tags for sortable functionality to work. The <th> tag defines a header cell in an HTML table.
You can use data-sort-name and data-sort-order in your table
For example :
<table data-toggle="table" data-sort-name="date" data-sort-order="desc">
The documentation is here http://bootstrap-table.wenzhixin.net.cn/documentation/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With