[jQuery] Re: tableSorter question: how to disable the last header?
Great. Perfect. Thanks. On Jan 25, 11:57 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi. I tried to use Widget or variable but without result. Than i edit table sorter plugin. It is very easy. In buildHeaders method after $tableHeaders = $(thead th,table); add this // set negative numbers like positive totalCols = $tableHeaders.length; for (var number in table.config.headers) { number = parseInt(number); if (number 0) table.config.headers[(totalCols + number)] = table.config.headers[number]; } and now numbering can be negative, but ONLY like string '-1': {sorter:false} On Jan 17, 10:13 pm, Leandro Vieira Pinho [EMAIL PROTECTED] wrote: Hi Guys, I would like to know, how to disable thelastheader. I don´t thelastcolumnwith the option to sort. I have tried it (see below) but withou success. var totalHeaders = ( $('table th').length - 1); $('table').tablesorter({ headers: { totalHeaders : { sorter: false } }, widgets: ['zebra'] }); OR $('table').tablesorter({ headers: { -1 : { sorter: false } }, widgets: ['zebra'] }); Some suggestion? Regards
[jQuery] Re: tableSorter question: how to disable the last header?
Hi. I tried to use Widget or variable but without result. Than i edit table sorter plugin. It is very easy. In buildHeaders method after $tableHeaders = $(thead th,table); add this // set negative numbers like positive totalCols = $tableHeaders.length; for (var number in table.config.headers) { number = parseInt(number); if (number 0) table.config.headers[(totalCols + number)] = table.config.headers[number]; } and now numbering can be negative, but ONLY like string '-1': {sorter:false} On Jan 17, 10:13 pm, Leandro Vieira Pinho [EMAIL PROTECTED] wrote: Hi Guys, I would like to know, how to disable thelastheader. I don´t thelastcolumnwith the option to sort. I have tried it (see below) but withou success. var totalHeaders = ( $('table th').length - 1); $('table').tablesorter({ headers: { totalHeaders : { sorter: false } }, widgets: ['zebra'] }); OR $('table').tablesorter({ headers: { -1 : { sorter: false } }, widgets: ['zebra'] }); Some suggestion? Regards
[jQuery] Re: TableSorter question
Try using something similar to the following: // TableSorter $('.reportTable').tableSorter({ sortColumn: 'date', // Integer or String of the name of the column to sort by. sortDir: 2, // Change the default sort direction to 2 (descending) sortClassAsc: 'headerSortUp', // Class name for ascending sorting action to header sortClassDesc: 'headerSortDown',// Class name for descending sorting action to header headerClass: 'header', // Class name for headers (th's) stripingRowClass: ['even','odd'],// Class names for striping supplyed as a array. stripeRowsOnStartUp: true, // Strip rows on tableSorter init. }); Notice the sortColumn and sortDir values. sortColumn takes a value based on the text between a th and /th. sortDir is defaulted to 0, and is used in a trinary operator to determine the default sort direction based on 'dir % 2', which basically says take the number 'dir' divide it by 2 and if 1, 'true' is the remainder then sort ascending, otherwise sort descending. Setting it to 2 reseults in a remainder of 0, 'false' so the default sort direction is now descending. I hope this helps. -- Michael Chris W. Parker wrote: I want my table to be sorted in the opposite direction that it's currently being sorted in when TableSorter does its first sort. I can't find a switch to do that but perhaps I'm not seeing it. Anyone know what it's called or should I just add my own? -- View this message in context: http://www.nabble.com/TableSorter-question-tf3548948s15494.html#a10953966 Sent from the JQuery mailing list archive at Nabble.com.
[jQuery] Re: TableSorter question
I haven't looked at the code, but when I see flatData.reverse() I wonder...are you sorting the regular way and then the reverse (as in two sorts) even if the sortDir is initially set to sort the reverse direction? If so, it might be nice to avoid that. - Original Message From: Chris W. Parker [EMAIL PROTECTED] To: jquery-en@googlegroups.com Sent: Monday, April 9, 2007 2:37:42 PM Subject: [jQuery] Re: TableSorter question On Monday, April 09, 2007 1:40 PM Chris W. Parker said: On Monday, April 09, 2007 12:43 PM Christian Bach said: tableSorter({ sortColumn: 0, sortDir: 1 }); Will sort the first column in the opposite direction. Actually that just makes my arrow appear upside down. Well I made some changes to the TableSorter file and now it works. I just hope I didn't introduce a bug. The original is around line 220 and reads like this: /** if we have a sortDir, reverse the damn thing. */ if(COLUMN_LAST_DIR != COLUMN_DIR) { flatData.reverse(); } I changed it to: /** if we have a sortDir, reverse the damn thing. */ if(defaults.sortDir == 1) { flatData.reverse(); } That seems to work fine. Chris.
[jQuery] Re: TableSorter question
There's an option for default sort. How is the data getting to the page? Is it hard-coded or the result of an SQL operation? -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Chris W. Parker Sent: Monday, April 09, 2007 1:58 PM To: jquery-en@googlegroups.com Subject: [jQuery] TableSorter question Hello, I want my table to be sorted in the opposite direction that it's currently being sorted in when TableSorter does its first sort. I can't find a switch to do that but perhaps I'm not seeing it. Anyone know what it's called or should I just add my own? Thanks, Chris.
[jQuery] Re: TableSorter question
On Monday, April 09, 2007 12:02 PM Andy Matthews said: There's an option for default sort. How is the data getting to the page? Is it hard-coded or the result of an SQL operation? It's both. I mean that it's not JSON or XML data. The data returned from the SQL call is used to create the table's HTML with PHP. Then TableSorter does its magic. Chris.
[jQuery] Re: TableSorter question
tableSorter({ sortColumn: 0, sortDir: 1 }); Will sort the first column in the opposite direction. /christian 2007/4/9, Chris W. Parker [EMAIL PROTECTED]: On Monday, April 09, 2007 12:02 PM Andy Matthews said: There's an option for default sort. How is the data getting to the page? Is it hard-coded or the result of an SQL operation? It's both. I mean that it's not JSON or XML data. The data returned from the SQL call is used to create the table's HTML with PHP. Then TableSorter does its magic. Chris. -- POLYESTER* Wittstocksgatan 2 115 24 Stockholm Phone: 08-660 73 50 / +46-8-660 73 50 Mobile: 070-443 91 90 / +46-70-443 91 90 E-mail: [EMAIL PROTECTED] http://www.polyester.se
[jQuery] Re: TableSorter question
On Monday, April 09, 2007 12:43 PM Christian Bach said: tableSorter({ sortColumn: 0, sortDir: 1 }); Will sort the first column in the opposite direction. Actually that just makes my arrow appear upside down. Here's what I see without sortDir set. Column up arrow April 9, 2007 April 10, 2007 April 11, 2007 Here's what I see with sortDir set to 1. Column down arrow April 9, 2007 April 10, 2007 April 11, 2007 Chris.
[jQuery] Re: TableSorter question
Sorry Chris, seems you found a bug. I checked in a new version that takes care of business. http://dev.jquery.com/browser/trunk/plugins/tablesorter/jquery.tablesorter.js?format=txt /christian 2007/4/9, Chris W. Parker [EMAIL PROTECTED]: On Monday, April 09, 2007 12:43 PM Christian Bach said: tableSorter({ sortColumn: 0, sortDir: 1 }); Will sort the first column in the opposite direction. Actually that just makes my arrow appear upside down. Here's what I see without sortDir set. Column up arrow April 9, 2007 April 10, 2007 April 11, 2007 Here's what I see with sortDir set to 1. Column down arrow April 9, 2007 April 10, 2007 April 11, 2007 Chris. -- POLYESTER* Wittstocksgatan 2 115 24 Stockholm Phone: 08-660 73 50 / +46-8-660 73 50 Mobile: 070-443 91 90 / +46-70-443 91 90 E-mail: [EMAIL PROTECTED] http://www.polyester.se