Feature request - custom orthogonal data types
Feature request - custom orthogonal data types
During my most recent project, I encountered a feature that would be helpful, particularly when using extensions. Namely, the ability to add additional orthogonal data types in addition to the built-in ones (order, display, filter, etc). For example, 'excel' or 'print' options to go with the options in the 'buttons' extension. While similar functionality can be done with a render function, that's much more complex than should be needed (I still haven't gotten it to work properly in my use case). An example of how this would appear:
<table class='table'>
<tr>
<td data-excel="Excel Formatted Data" data-print="Print Formatted Data">Some Data</td>
<td data-excel="Excel Formatted Data" data-print="Print Formatted Data">Some Data</td>
</tr>
</table>
$('table.table).dataTable( {
orthogonal: ['excel', 'print'],
buttons: [
{
extend: 'excel',
exportOptions: { orthogonal: 'excel' }
},
{
extend: 'print',
exportOptions: {orthogonal: 'print' }
}
]
});
My impressions from looking at the code are that this should be fairly reasonable to implement, but unfortunately, such implementation would have to happen in the core. My thoughts are, around line 1184-1198 of version 1.10.16,
if ( col.mData === i ) {
var sort = a( cell, 'sort' ) || a( cell, 'order' );
var filter = a( cell, 'filter' ) || a( cell, 'search' );
if ( sort !== null || filter !== null ) {
col.mData = {
_: i+'.display',
sort: sort !== null ? i+'.@data-'+sort : undefined,
type: sort !== null ? i+'.@data-'+sort : undefined,
filter: filter !== null ? i+'.@data-'+filter : undefined
};
_fnColumnOptions( oSettings, i );
}
for (var j = 0; j < oSettings.asOrthogonal.length; j++)
{
col.mData[oSettings.asOrthogonal[j]] = i+'.@data-' + oSettings.asOrthogonal[j];
}
}