bootstrap table 顯示連續序號,分頁有效

參考:http://blog.csdn.net/nazhidao/article/details/51647799bootstrap

 

第一種,經過index+1能夠簡單實現,可是,翻頁後又從新從第一個開始app

{  
    field: 'Number',  
    title: 'Number',  
    formatter: function (value, row, index) {  
    return index+1;  
    }  
} 

第二種,爲了可以實現,在翻頁時也能後接着上一頁的序號顯示,下邊修改bootstrap 的js庫:jsp

在bootstrap-table.js這個js庫中找到allowedMethods對象添加一個getPage屬性:(紅色部分爲本身添加,注意逗號)ide

 var allowedMethods = [
        'getSelections', 'getData',
        'load', 'append', 'remove',
        'updateRow',
        'mergeCells',
        'checkAll', 'uncheckAll',
        'check', 'uncheck',
        'refresh',
        'resetView',
        'destroy',
        'showLoading', 'hideLoading',
        'showColumn', 'hideColumn',
        'filterBy',
        'scrollTo',
        'prevPage', 'nextPage',
        'getPage'
    ];

而後,在js庫中,添加方法:this

 BootstrapTable.prototype.getPage = function (params) {  
        return {pageSize: this.options.pageSize, pageNumber: this.options.pageNumber};  
}; 

這樣就能夠在jsp中直接使用了:spa

 {
                         field:'',
                        title : '序號',
                        formatter : function (value, row, index){
                             var page = $('#task_list').bootstrapTable("getPage");  
                                return page.pageSize * (page.pageNumber - 1) + index + 1;  
                        }
                    },

結果:.net

相關文章
相關標籤/搜索