I have a table who's content is dynamically generated, prior to
calling table sort. In some cases this table may have a column - id of
which is "hdrTrailerID"
In the event this column is in the table, I want to set the
option explicitly to sort that column with the $.tablesorter.sortText
Consider the following:
- jQuery('#reportsTable').tablesorter({
-
widgets: [ 'zebra', 'resizable',
'stickyHeaders' ],
-
widgetOptions: {
-
resizable: true
-
},
-
textSorter:{
-
iCol: $.tablesorter.sortText
-
},
-
initialized:function(table){
-
alert(typeof iCol);
-
}
-
});
for the option headers, we have:
- textSorter:{
-
iCol: $.tablesorter.sortText
-
},
if i replace iCol with the value 4 (which is what it is assigned
above), the sorting works, but if I use the variable iCol instead of
the explicit number value it does not.
UPDATE:
After looking through the code, it appears that the problem we are
running into is one of object inheritance. So, after a little
fiddling, I came to the following solution:
- var
sortOptions = {};
-
sortOptions[iCol] = $.tablesorter.sortText;
Then I pass
sortOptions into the textSorter option and voila! Works perfectly!