bootstrap-table表格數據格式化


  //初始化表格
        function initTable() {
            var baseConfig = {
                uniqueId: "MemberID" //指定主鍵列
                , sortName: "CreateDate"  //默認排序列
                , sortOrder: "desc"
                , method: "post"
                , queryParams: that._methods.tableParams
                , pagination: true  //顯示分頁
                , sidePagination: 'server' //設置在哪里進行分頁,可選值為 'client' 或者 'server'。設置 'server'時,必須設置 服務器數據地址(url)或者重寫ajax方法
                , pageNumber: 1
                , pageSize: 20
                , pageList: [20, 30, 50]  //設置為 All 或者 Unlimited,則顯示所有記錄。
                , columns: [   //配置顯示列
                    { checkbox: false, width: 1 }
                    , { field: "MemberName", title: "客戶", width: 160, sortable: true }               
                    , {
                        field: "Status", title: "狀態", width: 100, sortable: true, formatter: function (val, row, index) {
                            if (val)
                                return val === 1 ? "啟用" : "禁用";
                            else
                                return val = "未配置";
                        }
                    }
                    , { field: "CreateUser", title: "創建人", width: 100, sortable: true }

                    , {  field: "CreateDate", title: "創建時間", width: 140, sortable: true, formatter: function (val, row, index) {
                            return val == null ? "" : _fn.ToDate(val).format('yyyy-MM-dd hh:mm:ss');
                        }
                    }
                    , {
                        field: "", title: "操作", width: 100, sortable: false, formatter: function (val, row, index) {
                            var config_div = "<div class='shelf_edit'><a onclick='_methods.ConfigModalShow(" + row.MemberID + ")' title='配置'>配置</a>";
                            if (row.Status == 1)
                                return config_div += "&nbsp;&nbsp;&nbsp;<a onclick='_methods.SwitchEnableStatus(" + row.MemberID + "," + row.Status + ")' title='禁用'>禁用</a></div>";
                            else
                                return config_div += "&nbsp;&nbsp;&nbsp;<a onclick='_methods.SwitchEnableStatus(" + row.MemberID + "," + row.Status + ")' title='啟用'>啟用</a></div>";
                        }
                    }
                ]
                , onLoadSuccess: function (data) { }
                , search: false
                , singleSelect: true
            };
            var tabConfig = _fn.GetTabDefaultConfig(baseConfig);
            that._doms.table.bootstrapTable(tabConfig);
        }

 

 

更多知識分享網址:http://www.itxst.com/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM