Bootstrap Table-Sort by custom data attribute
Sort by custom data attribute on a <td>
HTML
<link rel="stylesheet" href="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.css">
<script src="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.js"></script>
<table data-toggle="table"
>
<thead>
<tr>
<th data-field="fruit" data-sortable="true">Item</th>
<th data-field="date" data-sortable="true">Date</th>
<th data-field="type" data-sortable="true">Type</th>
</tr>
</thead>
<tbody>
<tr><td>Pear </td><td data-month="1">January</td> <td>Fruit</td></tr>
<tr><td>Carrot</td><td data-month="3">March</td> <td>Vegetable</td></tr>
<tr><td>Apple </td><td data-month="2">February</td><td>Fruit</td></tr>
</tbody>
</table>
<button>
Sort by item
</button>
</button>
JavaScript
$(function() {
$("th[data-field='fruit'] .sortable").click();
});
$("button").on("click", function() {
$("th[data-field='fruit'] .sortable").click();
});