Am new to Bootstrap, i have a requirement to show a table with sort up and down arrow near to title of the table. This is my table structure
<table class="table table-bordered table-striped">
<thead>
<tr>
<th><b>#</b> <i class='icon-arrow-up'></i><i class='icon-arrow-down'></th> **// tried**
<th ><b>Name</b></th>
<th><b>Email</b></th>
<th><b>Team</b></th>
<th ><b>Role</b></th>
<th ><b>Timezone</b></th>
<th><b>Connections</b></th>
<th><b># Posts available</b></th>
<th><b>Last Login</b></th>
<th><b>Posts</b></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
I want to display sort up/down arrows similar to the following image.
Please help me to solve this issue. Your help is much appreciated. Thank you.
Sort Table by Clicking the Headers. Click the headers to sort the table. Click "Name" to sort by names, and "Country" to sort by country. The first time you click, the sorting direction is ascending (A to Z).
For sorting the records in a table, you may use data attributes at the table or <th> tags. Specify the default column that you want to sort as web page loads at table tag: e.g. Similarly, add the data attribute data-sortable=”true” to the columns where you want to enable sorting in that HTML table.
How to Make Sortable Tables. 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.
To arrange icons by name, type, date, or size, right-click a blank area on the desktop, and then click Arrange Icons. Click the command that indicates how you want to arrange the icons (by Name, by Type, and so on). If you want the icons to be automatically arranged, click Auto Arrange.
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.
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
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