本文介绍了如何在Backbone.js的动态地使用引导mergeCells的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这将创建一个自举表函数,我必须在该表中合并动态只有特定的列。
I have a function which creates a bootstrap table and i have to merge only specific columns in that table dynamically.
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,
events : this.linkEvents
formatter :this.linkFormatter
}
]
});
linkEvent功能:
linkEvent function:
linkEvents: {
'onPostBody #Table1': function(e,value,row,index) {
console.log("Inside post-body event");
$('#Table1').bootstrapTable('mergeCells',{
index:6,
colspan:2
});
}
}
即使上面的code犯规的工作是不是mergeCells方法中来。请帮我在这。
even the above code doesnt working it is not coming inside the mergeCells method. Please help me on this..
推荐答案
最后发现@Frogmouth的帮助(真正伟大的支持)的答案..
改变code如下:
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;
}
}
]
});
//无需linkEvents功能。相反,使用jQuery
//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.
});
}
});
});
感谢
这篇关于如何在Backbone.js的动态地使用引导mergeCells的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!