Render and multiple tables in 1.10.3
Render and multiple tables in 1.10.3
I am in the process of upgrading from 1.9 to 1.10.3 and am noticing an issue with render and having multiple tables on one page.
I have two tables, and in each there is a column that I use the render function to convert to a link. If I use the render in both tables, the second table will have a messed up link, because the render is applied twice. If I comment out the render in the second table, the column that needs to be linkified in that table will be linkified, even with no render setup for that particular table. It seems that the render from the first table is linkifying the second. Any idea on what's going on? Is this a bug, or something I have configured incorrectly.
Table 1
oTable = $('#channelTable').DataTable( {
"lengthMenu": [
[25, 50, 100, 200, -1],
[25, 50, 100, 200, "All"]
],
"order": [[ 0, "desc" ]],
"dom": 'CTR<"clear">lfrtip',
"columnDefs": [ {
"targets": 6,
"data": "accountNumber",
"render": function ( data, type, full, meta ) {
return '<a href="' + base_url + 'filter/account/' + data + '">' + data + '</a>';
}
} ],
"columns" : [ {"visible": false},
null,
null,
null,
null,
{"visible": false},
null,
null,
null,
null,
null,
null,
null,
null,
null,
{"visible": false},
{"visible": false},
{"visible": false},
{"visible": false},
{"visible": false},
{"visible": false},
null
],
"tableTools": {
"sSwfPath": base_url + "assets/DataTables-1.10.3/extensions/TableTools/swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "copy",
"mColumns": "visible"
},
{
"sExtends": "collection",
"sButtonText": "CSV",
"aButtons": [
{
"sExtends": "csv",
"sButtonText": "All Columns",
"sTitle": "FilteredData"
},
{
"sExtends": "csv",
"sButtonText": "Visible Columns",
"sTitle": "FilteredData",
"mColumns": "visible"
}, ]
},
{
"sExtends": "print",
"mColumns": "visible"
}
]
},
"language": {
"search": "Search all columns:"
},
"orderCellsTop": true,
"autoWidth": false,
"pageLength": 25,
"pagingType": "full_numbers"
} );
Table 2
oTable2 = $('#additionsTable').DataTable( {
"lengthMenu": [
[25, 50, 100, 200, -1],
[25, 50, 100, 200, "All"]
],
"order": [[ 0, "desc" ]],
"dom": 'CTR<"clear">lfrtip',
/*
"columnDefs": [ {
"targets": 6,
"data": "accountNumber",
"render": function ( data, type, full, meta ) {
return '<a href="' + base_url + 'filter/account/' + data + '">' + data + '</a>';
}
} ],
*/
"columns" : [ {"visible": false},
null,
null,
null,
null,
{"visible": false},
null,
null,
null,
null,
null,
null,
null,
null,
null,
{"visible": false},
{"visible": false},
{"visible": false},
{"visible": false},
{"visible": false},
{"visible": false},
null,
null
],
"tableTools": {
"sSwfPath": base_url + "assets/DataTables-1.10.3/extensions/TableTools/swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "copy",
"mColumns": "visible"
},
{
"sExtends": "collection",
"sButtonText": "CSV",
"aButtons": [
{
"sExtends": "csv",
"sButtonText": "All Columns",
"sTitle": "FilteredData"
},
{
"sExtends": "csv",
"sButtonText": "Visible Columns",
"sTitle": "FilteredData",
"mColumns": "visible"
}, ]
},
{
"sExtends": "print",
"mColumns": "visible"
}
]
},
"language": {
"search": "Search all columns:"
},
"orderCellsTop": true,
"autoWidth": false,
"pageLength": 25,
"pagingType": "full_numbers"
} );
This question has an accepted answers - jump to answer
Answers
Can you link to a test page showing the issue please?
Allan
I was able to get this working. One of my tables that I was converting to use the Render, I had not removed the code from my PHP that was also adding a link to the column, and that's why it was duplicating. I missed it earlier when I was testing it out. Thanks for a great product.