How to show Bootstrap table with sort icon
BOOTSTRAP 4
you can use a combination of
fa-chevron-down, fa-chevron-up
fa-sort-down, fa-sort-up
<th class="text-center">
<div class="btn-group" role="group">
<button type="button" class="btn btn-xs btn-link py-0 pl-0 pr-1">
Some Text OR icon
</button>
<div class="btn-group-vertical">
<a href="?sort=asc" class="btn btn-xs btn-link p-0">
<i class="fas fa-sort-up"></i>
</a>
<a href="?sort=desc" class="btn btn-xs btn-link p-0">
<i class="fas fa-sort-down"></i>
</a>
</div>
</div>
</th>
Use this icons with bootstrap (glyphicon):
<span class="glyphicon glyphicon-triangle-bottom"></span>
<span class="glyphicon glyphicon-triangle-top"></span>
http://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_ref_glyph_triangle-bottom&stacked=h
http://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_ref_glyph_triangle-bottom&stacked=h
You could try using FontAwesome. It contains a sort-icon (http://fontawesome.io/icon/sort/).
To do so, you would
need to include fontawesome:
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
and then simply use the fontawesome-icon instead of the default-bootstrap-icons in your
th
's:<th><b>#</b> <i class="fa fa-fw fa-sort"></i></th>
Hope that helps.