SOLVED tablesorter with dynamic data, setting sorter for a column whose index is referenced by a variable

SOLVED tablesorter with dynamic data, setting sorter for a column whose index is referenced by a variable

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:
 
  1. jQuery('#reportsTable').tablesorter({
  2.                 widgets: [ 'zebra', 'resizable', 'stickyHeaders' ],
  3.                 widgetOptions: {
  4.                     resizable: true
  5.                 },
  6.                 textSorter:{
  7.                             iCol: $.tablesorter.sortText
  8.                 },
  9.                 initialized:function(table){
  10.                     alert(typeof iCol);
  11.                 }
  12.             });

for the option headers, we have:

  1.  textSorter:{
  2.                     iCol: $.tablesorter.sortText
  3.                 },

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:

  1. var sortOptions = {};
  2.  sortOptions[iCol] = $.tablesorter.sortText;
Then I pass sortOptions into the textSorter option and voila! Works perfectly!
  1. textSorter:sortOptions