How to access a second column in an external sort plugin
How to access a second column in an external sort plugin

I currently have an external sort plugin to sort a single column based on a conditional in the pre-amble:
jQuery.extend( jQuery.fn.dataTableExt.oSort,{
"enum-pre": function ( column_1 ) {
switch( column_1 ) {
case "A": return 1;
case "B": return 2;
case "C": return 3;
default: return 4;
I now need to include data from another column into that conditional:
"enum-pre": function ( column_1, column_2 ) {
if (column_1 = 'A' and column_2 = 'X') return 1;
if (column_1 = 'B' and column_2 = 'Y') return 2;
Is there an "approved" way to go about accessing the second column?
Thanks
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
No - I'm afraid you can't. The sorting plug-ins are given the data for the target column only and have no access to the data in the other columns.
If you want to sort a column over two columns of data you either need to:
columns.orderData
to sort over multiple columns (note that they are still sorted by data independently - the second column's data will only be used if the first one has the same data in two rows - think multi-column sorting).Allan
Allan;
As always, thanks for getting back to me so quickly. Disappointing to hear, but I understand.
Already using orderData, but as you point out, it is limited as a "secondary", and I need it to be interwoven in the pre-amble of first. I will try to be creative.
Thanks again.