【问题标题】:Datatable remove specific div from row during export to csv数据表在导出到 csv 期间从行中删除特定 div
【发布时间】:2020-06-06 16:17:15
【问题描述】:
请查看下表,了解我想要导出到 csv 的内容。
我用过Datatable。我想在导出到csv 期间删除/隐藏removeit 类及其内容。
<table>
<tr>
<th>First Name</th>
</tr>
<tr>
<td>John doe <div class="removeit">Remove this content</div></td>
</tr>
</table>
【问题讨论】:
标签:
php
jquery
html
wordpress
datatable
【解决方案1】:
Here, I found solution by myself.
buttons: [
{
extend: 'csvHtml5',
text: 'Export to Csv',
exportOptions: {
format: {
body: function ( data, row, column, node, type ) {
if(column==0){
var lines = data.split('<div');
var count_d = 0;
jQuery.each(lines, function() {
if(count_d==0){
data = this;
}
count_d++;
});
}
else{
data = data;
}
return data;
}
}
}
}
],