bootStrap-table 行號 順序排列


項目中用到很多表格來展示數據 分頁 以及行號顯示   bootStrap-table顯示行號最簡單的便是 使用其自身的 index 屬性 通過 data-formatter來調用方法 展示行號

function setCode(val, row, index) {
               return index + 1;
    }

但是注意 這個是每頁展示都是從1開始  而不是接着上一頁順序的   所以這就美麗了  。而現在我們需要是接着上一頁的的序號顯示 而不是每頁都從1開始。知道了計算方法就是獲取到

pageSize(每頁顯示的條數)和 pageNumber(當前第幾頁) ,那就取唄,關鍵是這兩項是不可以直接使用的   所以就只能在源碼里 寫方法來獲取到這兩項,這也是在網上幾經查詢找到的   感謝大神們   慢慢向你們靠近 慢慢修煉  

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

然后把 getPageCode 方法 放在 allowedMethods 對象里

  var allowedMethods = [
        'getOptions','getPageCode',
        'getSelections', 'getAllSelections', 'getData',
        'load', 'append', 'prepend', 'remove', 'removeAll',
        'insertRow', 'updateRow', 'updateCell', 'updateByUniqueId', 'removeByUniqueId',
        'getRowByUniqueId', 'showRow', 'hideRow', 'getHiddenRows',
        'mergeCells',
        'checkAll', 'uncheckAll', 'checkInvert',
        'check', 'uncheck',
        'checkBy', 'uncheckBy',
        'refresh',
        'resetView',
        'resetWidth',
        'destroy',
        'showLoading', 'hideLoading',
        'showColumn', 'hideColumn', 'getHiddenColumns', 'getVisibleColumns',
        'showAllColumns', 'hideAllColumns',
        'filterBy',
        'scrollTo',
        'getScrollPosition',
        'selectPage', 'prevPage', 'nextPage',
        'togglePagination',
        'toggleView',
        'refreshOptions',
        'resetSearch',
        'expandRow', 'collapseRow', 'expandAllRows', 'collapseAllRows',
        'updateFormatText'
    ];

然后通過 data-formatter來調用getPageCode方法就OK啦 !這樣就會是選哪個要的連續編號了


免責聲明!

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



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