Section Html, ordered set style table header
<table id="contentTable" class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>序号</th>
<th id="packCntTh" class="sortCls" data-type="packCnt">排序字段(包裹数量) <i></i></th>
</tr>
</thead>
<tbody><td></td><td></td></tbody>
</table>
Mouse small display is provided on the hand shape
<style type="text/css">
.sortCls{
cursor:pointer;
}
</style>
When a mouse click to sort a column, the default is descending, ascending again click, click descending order, adding up or down arrow
<script type="text/javascript">
$(document).ready(function(){
$(".sortCls").click(function(){
var sortColumn = $(this).data('type');
var sortType;
if($(this).find("i").hasClass("icon-arrow-down")){
sortType = "asc";
$("i").attr("class", "");
$(this).find("i").addClass("icon-arrow-up");
}else if($(this).find("i").hasClass("icon-arrow-up")){
sortType = "desc";
$("i").attr("class", "");
$(this).find("i").addClass("icon-arrow-down");
}else{
$("i").attr("class", "");
$(this).find("i").addClass("icon-arrow-down");
sortType = "desc";
}
//table 设置两个隐藏域,用于向后台传递排序字段和排序方式(降序/升序)
$("#sortType").attr("value",sortType);
$("#sortColumn").attr("value",sortColumn);
//提交Table所在的Form表单,发起请求
$("#searchForm").attr("action","${ctx}/doSearchUrl");
$("#searchForm").submit();
loading('正在查询,请稍等...');
});
});
</script>