Javascript Datatables(2.1.4)如何使用aButtons更改csv内容
在我的表格中,有一列值是“google”,当用户单击它时,它将成为指向google网站的链接。但当用户想要导出csv内容时,我想将google值改为链接。目前,csv内容只是谷歌文本Javascript Datatables(2.1.4)如何使用aButtons更改csv内容,javascript,csv,datatables,Javascript,Csv,Datatables,在我的表格中,有一列值是“google”,当用户单击它时,它将成为指向google网站的链接。但当用户想要导出csv内容时,我想将google值改为链接。目前,csv内容只是谷歌文本 { "sExtends": "csv", "sButtonText": "export CSV", "sCharSet": "utf8",//solve csv chinese encoded problem "bBomInc": true,//solve csv c
{
"sExtends": "csv",
"sButtonText": "export CSV",
"sCharSet": "utf8",//solve csv chinese encoded problem
"bBomInc": true,//solve csv chinese encoded problem
"fnCellRender": function ( sValue, iColumn, nTr, iDataIndex ) {
if(sValue.toString().match("href")){
return $(sValue).attr("href");
}
return sValue;
}//to make some change to the cell content before export the csv
}
如何在“我的按钮”功能中执行此操作?
{
"sExtends": "csv",
"sButtonText": "export CSV",
"sCharSet": "utf8",//solve csv chinese encoded problem
"bBomInc": true,//solve csv chinese encoded problem
"fnCellRender": function ( sValue, iColumn, nTr, iDataIndex ) {
if(sValue.toString().match("href")){
return $(sValue).attr("href");
}
return sValue;
}//to make some change to the cell content before export the csv
}
我的代码:
"oTableTools": {
"sSwfPath": "http://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "csv",
"sButtonText": "export csv",
}
]
}
{
"sExtends": "csv",
"sButtonText": "export CSV",
"sCharSet": "utf8",//solve csv chinese encoded problem
"bBomInc": true,//solve csv chinese encoded problem
"fnCellRender": function ( sValue, iColumn, nTr, iDataIndex ) {
if(sValue.toString().match("href")){
return $(sValue).attr("href");
}
return sValue;
}//to make some change to the cell content before export the csv
}
我在aButtons中添加了fnCellRender函数,如下所示,以对csv内容进行一些更改
{
"sExtends": "csv",
"sButtonText": "export CSV",
"sCharSet": "utf8",//solve csv chinese encoded problem
"bBomInc": true,//solve csv chinese encoded problem
"fnCellRender": function ( sValue, iColumn, nTr, iDataIndex ) {
if(sValue.toString().match("href")){
return $(sValue).attr("href");
}
return sValue;
}//to make some change to the cell content before export the csv
}