• BootstrapTable表格点击字段排序


     
    <table id="group-table" data-toggle="table" class="table table-striped table-hover" style="border: 1px solid #e4eaec; margin-top: 10px;"></table>
    //获取共享组
    var $groupTable = $('#group-table').bootstrapTable('destroy').bootstrapTable({
        url: '/kscd/api/share-group/',
        method: 'GET',
        dataType: "json",
        uniqueId: 'id',                        
        striped: false,                         
        cache: false, 
        sortName: 'id',
        sortable: true,
        sortOrder: 'desc',
        sidePagination: "server",
        undefinedText: '--',
        singleSelect: true,
        //showRefresh   : true,
        //showColumns   : true,
        toolbar: '#group-table-toolbar',
        search: true,
        strictSearch: true,
        clickToSelect: true,
        pagination: true,
        pageNumber:1,
        pageSize:10,
        pageList: [5, 10, 20, 50, 100],
        paginationPreText:"上一页",
        paginationNextText:"下一页",
        //showToggle: true,
        //cardView: false,
        //detailView: false,
        //showPaginationSwitch: true,
        queryParamsType : "",
        queryParams : function (params) {
            var temp = {
                'pageSize' : params.pageSize,
                'pageNumber' : params.pageNumber,
                'searchText': params.searchText,
                'sortName': params.sortName,
                'sortOrder': params.sortOrder,
            };
            return temp;
        },
        columns: [
                  {
                     checkbox: true
                  },{
                     field: 'name',
                     title:'名称',
                      '16%',
                     sortable : true
                  },{
                     field: 'create_time',
                     title:'创建时间',
                     sortable : true,
                      200
                  },{
                     field: 'description',
                     title:'描述'
                  }
        ],
        onLoadSuccess: function () {
            //alert('表格加载成功!');
        },
        onLoadError: function () {
            //showTips("数据加载失败!");
        },
        onClickRow: function (row, $element) {
            var id = row.id;
            //EditViewById(id, 'view');
            //console.log(row);
        },
        onCheck: function (row, $element) {
            chosenGroupId = row.id;
            $userTable.bootstrapTable("refresh");
            //EditViewById(id, 'view');
        },
        onUncheck: function (row, $element) {
            chosenGroupId = "";
            $userTable.bootstrapTable("removeAll");
            $userTable.bootstrapTable("refresh");
            //EditViewById(id, 'view');
        }
    });
    

     要设置排序的字段加上属性“sortable : true”。

    queryParams : function (params) {
            var temp = {
                'pageSize' : params.pageSize,
                'pageNumber' : params.pageNumber,
                'searchText': params.searchText,
                'sortName': params.sortName,
                'sortOrder': params.sortOrder,
            };
            return temp;
    }

    中加上属性:

    'sortName': params.sortName,
    'sortOrder': params.sortOrder
  • 相关阅读:
    use paramiko to connect remote server and execute command
    protect golang source code
    adjust jedi vim to python2 and python3
    install vim plugin local file offline
    add swap file if you only have 1G RAM
    datatables hyperlink in td
    django rest framework custom json format
    【JAVA基础】网络编程
    【JAVA基础】多线程
    【JAVA基础】String类的概述和使用
  • 原文地址:https://www.cnblogs.com/samve/p/14198982.html
Copyright © 2020-2023  润新知