bootstrap table表头字段排序

var col = [{
    field: 'checked',
    checkbox: true,
    align: 'center'
}, {
    field: 'id',
    title: 'id',
    align: 'center'
}, {
    field: 'PROJECT_NAME',
    title: '项目名称',
    align: 'center'
}, {
    field: 'CONTRACT_DATE',
    title: '合同签订日期',
    align: 'center'
}, {
    field: 'WORKLOAD',
    title: '工作量(人天)',
    align: 'center'
}, {
    field: 'TOTAL_AMOUNT',
    title: '项目金额',
    align: 'center'
}, {
    field: 'PAY_AMOUNT',
    title: '已收金额',
    class: 'aa',
    formatter: function (value, row, index) {
        if(value>=row.TOTAL_AMOUNT&&row.TOTAL_AMOUNT>0){
            return "<img src='#(ctx)/common/img/over2.png' style='width: 50px;height: 100%'/>";
        }else{
            return value;
        }
    },
    align: 'center'
}, {
    field: 'LASTMODIFIEDDATETIME',
    title: '更新日期',
    sortable:true,
    align: 'center'
}, {
    field: 'control',
    title: '操作',
    align: 'center',
    formatter: function (value, row, index) {
        //通过formatter可以自定义列显示的内容
        var a='';
        if (!(row.PAY_AMOUNT >= row.TOTAL_AMOUNT && row.TOTAL_AMOUNT > 0)) {//未结款加载按钮
            a = a + '#if(shiro.hasPermission("admin:project:fee"))<a class="label label-table label-info" onclick="changeFee(' + row.id + ',' + row.TOTAL_AMOUNT + ')" href="javascript:void(0);" >收款</a>&nbsp;#end';
            a = a + '#if(shiro.hasPermission("admin:demand:update"))<a class="label label-table label-success" onclick="doPjax(\'' + ctx + '/demandManage/makeContract?id=' + row.id + '\')" href="javascript:void(0);" >编辑</a>&nbsp;#end';
        }
        a = a + '#if(shiro.hasPermission("admin:project:delete"))<a class="label label-table label-danger" onclick="del(\'' + row.id + '\')" href="javascript:void(0);" >删除</a>&nbsp;#end';
        a = a + '#if(shiro.hasPermission("admin:project:view"))<a class="label label-table label-mint" onclick="doPjax(\'' + ctx + '/project/view?id=' + row.id + '\')" href="javascript:void(0);" >查看</a>&nbsp;#end';
        a = a + '#if(shiro.hasPermission("admin:project:flolo"))<a class="label label-table label-mint" onclick="doPjax(\'' + ctx + '/project/follow?id=' + row.id + '\')" href="javascript:void(0);" >跟进</a>&nbsp;#end';
        return a;
    }
}];
var opt = {
    //请求方法
    method: 'get',
    //是否显示行间隔色
    striped: true,
    //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*    cache: false,
    //data-toolbar: "#demo-delete-row",
    //是否显示分页(*    pagination: true,
    //是否启用排序
    sortable: true,
    //排序方式
    sortOrder: "desc",//排序
    sortName: 'LASTMODIFIEDDATETIME',//排序字段
    //初始化加载第一页,默认第一页
    //我设置了这一项,但是貌似没起作用,而且我这默认是0,- -
    //pageNumber:1,
    //每页的记录行数(*    pageSize: 5,
    //可供选择的每页的行数(*    pageList: [5, 10, 20, 50],
    //这个接口需要处理bootstrap table传递的固定参数,并返回特定格式的json数据
    url: ctx + "/project/listData",
    //默认值为 'limit',传给服务端的参数为:limit, offset, search, sort, order Else
    queryParamsType: '',
    //分页方式:client客户端分页,server服务端分页(*    sidePagination: "server",
    //是否显示搜索
    search: true,
    //Enable the strict search.
    strictSearch: true,
    //Indicate which field is an identity field.
    idField: "id",
    columns: col,
    pagination: true
};

//表格
function initTable() {
    $('#projectTable').bootstrapTable(opt);
    $('#projectTable').bootstrapTable('hideColumn', 'id');
}

猜你喜欢

转载自blog.csdn.net/qq_34815027/article/details/78247042