Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap table default sorting

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)

like image 911
MSG3260 Avatar asked Jan 19 '17 12:01

MSG3260


People also ask

How do I sort data in bootstrap table?

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.

What is table sorting?

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.

How do I make a table sortable in HTML?

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.


1 Answers

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/

like image 152
Gautier Avatar answered Sep 30 '22 01:09

Gautier