fnCellRender - Copied 0 rows to clipboard
fnCellRender - Copied 0 rows to clipboard
wilsontc
Posts: 6Questions: 2Answers: 1
I'm trying to use fnCellRendrer to preprocess cell data before exporting it. Everything works as expected when I don't extend the button, but when I try a simple proof of concept for extending a button, I get Copied 0 rows to clipboard.
Here is the relevant code:
tableTools = new $.fn.dataTable.TableTools( msTable, {
"sSwfPath": "/assets/dataTables/extras/swf/copy_csv_xls_pdf.swf"
"aButtons": [
{
"sExtends": "copy",
"fnCellRender": ( sValue, iColumn, nTr, iDataIndex ) ->
msName = sValue
if iColumn == 0
msName = $(sValue).find('.ms-assoc-pnl')[0].innerHTML.trim()
console.log msName
return msName
},
"csv",
"xls",
"pdf",
"print"
]
} )
This discussion has been closed.
Answers
I found the issue. The last row in my table is actually a form that allows you to create a new row. As such it doesn't have the .ms-assoc-pnl class, so the find was coming up empty. Everything failed silently after that.
I just separated the find from the rest of that line and checked whether the length of the result was > 0 before going after the innerHTML.