how to use bootstrap mergeCells dynamically in backbone.js

蓝咒 提交于 2019-12-08 07:39:27

Finally found the answer with the help of @Frogmouth(really great support).. change the code as following :

var keys=[];
this.$('#Table1').bootstrapTable({
        striped: false,
        minimumCountColumns: 2,
        smartDisplay:true,
        clickToSelect: false,
        columns:[
             {
                field:'Key2',
                title: $.t('report:'+code+'.Col2'),
                align: 'left',
                valign: 'middle', 
                sortable: true,
                formatter :function(value, row, index){
                           var rowValue = row.Data.Key2;
                           if(rowValue.trim()==''){ // if column value is empty those columns have to be merged
                            keys.push(index);
                           }                        
                           return row.Data.detailIndKey2;
                           }
             }
        ]
     });

//no need of linkEvents function. Instead use jquery

$(function () { 
$('#Table1').on('post-body.bs.table', function (e, data) {
for(var i=0;i<keys.length;i++){
$('#Table1').bootstrapTable('mergeCells',{
index:keys[i], //for dynamic keys
field:'Key1',
colspan:4 // how many columns have to be merged.
});
}
}); 
});

thanks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!