Bootstrap按照某个字段排序

章高朗
2023-12-01
以下示例代码是按照lastUpdatetime字段排序的,只需要在option中指定sortName:排序字段,sortOrder:'排序规则',然后在columns中的lastUpdatetime下添加sortable: true这个属性即可。
var options = {
    id: "bootstrap-table",
    url: prefix + "/list",
    queryParams: queryParams1,
    createUrl: prefix + "/add",
    updateUrl: prefix + "/edit/{id}",
    modalName: "业务模块",
    sortName: "lastUpdatetime",//排序字段
    sortOrder: "desc",//排序规则
    columns: [
        {
            field: '',
            title: '序号',
            align: "center",
            formatter: function (value, row, index) {
                return index + 1;
            }
        },

 
        {
            field: 'contractStime',
            title: '开始日'
        },
        {
            field: 'contractEtime',
            title: '結束日'
        },

        {
            field: 'lastUpdatetime',
            title: '最后更新时间',
            sortable: true
        },
        
        {
            title: '操作',
            align: 'center',
            formatter: function(value, row, index) {
                var actions = [];
                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" οnclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                return actions.join('');
            }
        }]
};
$.table.init(options);

示例代码中是按照最后更新时间倒序排序。

 类似资料: