BootstrapmergeCells合并單元格(多列)

/**

站在用戶的角度思考問題,與客戶深入溝通,找到寧晉網(wǎng)站設計與寧晉網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:網(wǎng)站建設、網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、域名與空間、網(wǎng)站空間、企業(yè)郵箱。業(yè)務覆蓋寧晉地區(qū)。

  • 合并單元格
  • @param target 目標表格對象
  • @param data 原始數(shù)據(jù)(在服務端完成排序)
  • @param fieldName 合并參照的屬性名稱
  • @param fieldList 要合并的字段集合[不含fieldName]![]
  • @param colspan 合并開始列
    */
    function mergeCells(target, data, fieldName, fieldList, colspan) {
    // 聲明一個map計算相同屬性值在data對象出現(xiàn)的次數(shù)和
    var sortMap = {};
    var index = 0;
    var begini=0;
    var endi = 0;
    // 統(tǒng)計fieldName長度
    getCount(target, data, 0, data.length, fieldName, index, sortMap);
    for(var prop in sortMap){
    endi = index+sortMap[prop];
    if(sortMap[prop]>1){
    // console.log(fieldName + ":" + prop,sortMap[prop]);
    for(var i=0;i<fieldList.length;i++){
    getCount(target, data, begini, endi, fieldList[i], index, null);
    }
    }
    index = begini = endi;
    }

}

/**

  • 計算合并
    /
    function getCount(target, data, begini, endi, fieldName, index, sortMap) {
    // console.log('fieldName:' + fieldName);
    // console.log(begini,endi);
    if(sortMap == null){
    sortMap = {};
    }
    for(var i = begini ; i < endi ; i++){
    for(var prop in data[i]){
    if(prop == fieldName){
    var key = data[i][prop];
    if(sortMap.hasOwnProperty(key)){
    sortMap[key] = sortMap[key]
    1 + 1;
    } else {
    sortMap[key] = 1;
    }
    // console.log(fieldName + ":" + key, sortMap[key]);
    break;
    }
    }
    }
    for(var p in sortMap){
    var count = sortMap[p] * 1;
    // console.log(">>>>>" + ":" + p , count);
    $(target).bootstrapTable('mergeCells',{index:index, field:fieldName, colspan: 1, rowspan: count});
    index += count;
    }

}

使用:
var data1 = $('#table').bootstrapTable('getData', true);
mergeCells($('#table'), data1, "proname", ["promonth", "pkno", "zb"], 1);

Bootstrap mergeCells合并單元格(多列)

當前名稱:BootstrapmergeCells合并單元格(多列)
文章鏈接:http://muchs.cn/article24/pisoce.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供云服務器、營銷型網(wǎng)站建設、微信公眾號網(wǎng)站設計公司、電子商務品牌網(wǎng)站建設

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司