DataTables插件似乎不允许自定义渲染。在数据表中自定义渲染
我们可以初始化使用aTargets和mRender定制单元格呈现:
"aoColumnDefs": [{
"aTargets": [transaction_id_index],
"mRender": function (data, type, row) {
return 'custom '+data;
}
}]
我该怎么办表头是一回事吗?
注:我使用显示和隐藏功能,所以我不能直接修改aColumns中的sTitle。
编辑
我想,以尽量减少列宽重命名列标题。我得到了这样的标题:“foo_bar”。 现在我使用的这一点,但它不是最好的办法是肯定的:
'fnInitComplete': function(oSettings, json){
$(table).find("thead tr th").each(function(index) {
$(this).html($(this).html().split("_").join("<br>"));
});
},
"fnDrawCallback": function(oSettings) {
// TO IMPROVE
$(table).find("thead tr th").each(function() {
if($(this).text().indexOf("_") !== -1) {
$(this).html($(this).text().split("_").join("<br>"));
}
});
}
感谢@kabstergo的提示! 我不关闭这个问题,因为我的解决方案不是“干净”的。
这是一个良好的开端和好于另一funtion修改!我的问题是:在初始化时隐藏列(使用“bVisible”:false)。调用切换列可见性的fnShowHide()函数时,修改标题的最佳方法是什么? – fdubrez