TableSorter with defined width columns

TableSorter with defined width columns

Hi,

I would like to go on using TableSorter plug-in with Pager companion for formatting tables but I also have, in some cases, to defined the width of each columns.

I tried to find a solution in ancient posts but failed, so here is the solution I purpose.
Nevertheless, if another more elegant solution has been provided, I would adopt it straight away.

In the function buildHeaders, I check if a width parameter has been provided for the column and, if it has, I set the css/width property.
That is, line 315 :








  1. if((table.config.headers[index]) && (table.config.headers[index].width)) {
  2.   $(this).css('width', table.config.headers[index].width);
  3. }


Then, when constructing the html/table, ie :

  1. .tablesorter({
  2.   headers: { 1: {width: '100px' }
  3. })



As I searched for weeks unsuccessfully, maybe this would help some others.



Olivier