Hi Richard. thanks for your reply unfortunately looks like I have some trouble to make the code works.
If I call the second options everything works fine but with yours the headers are still sortable. $('.scrolling_table').tablesorter({ headers: h1 }); $('.scrolling_table').tablesorter({ headers: {0: { sorter: false }, 1: { sorter: false }, 2: { sorter: false }}}); Moreover, looking at tablesorter documentation I have just noticed the best way to achieve my goal is using class="{sorter: false}" for the header I don't want to be sortable but also in this case I have some troubles. My table looks like <table class="scrolling_table"> <thead> <tr> <th width="3%" class="{sorter: false}"> </th> <th width="3%" class="{sorter: false}"> </th> <th width="3%" class="{sorter: false}"> </th> <th width="36%">task</th> <th width="20%">user</th> <th width="15%">date</th> <th width="20%">pred</th> </tr> </thead> <tbody id="tbody_0"> <tr class="even" id="task_563"> <td class="item_cell">-</td> <td class="item_cell">-</td> <td class="item_cell">-</td> <td class="item_cell">task 1</td> <td class="item_cell">joe</td> <td class="item_cell">11/11/2009</td> <td class="item_cell">no</td> </tr> <tr class="even" id="task_564"> <td class="item_cell">-</td> <td class="item_cell">-</td> <td class="item_cell">-</td> <td class="item_cell">task 2</td> <td class="item_cell">joe</td> <td class="item_cell">11/12/2009</td> <td class="item_cell">no</td> </tr> <tr class="even" id="task_568"> <td class="item_cell">-</td> <td class="item_cell">-</td> <td class="item_cell">-</td> <td class="item_cell">task 4</td> <td class="item_cell">mark</td> <td class="item_cell">11/18/2009</td> <td class="item_cell">yes</td> </tr> </tbody> </table> Am I missing something? Thanks again Sig On Sep 24, 5:15 pm, "Richard D. Worth" <rdwo...@gmail.com> wrote: > function createHeaders(ary) { > var headers = {}; > $(ary).each(function() { > headers[this] = { sorter: false }; > }); > return headers; > > } > > var a1 = [0,1,2], a2 = [0,4,5,8]; > var h1 = createHeaders(a1), h2 = createHeaders(a2); > > $(this).tablesorter({ headers: h1 }); > > $(this).tablesorter({ headers: h2 }); > > - Richard > > > > On Thu, Sep 24, 2009 at 6:44 PM, macsig <sigbac...@gmail.com> wrote: > > > I know this is not strictly related to jquery but I don't know how to > > make it works. > > > I'm working on a function that has as variable an array and for each > > element I need to create a piece of code for an other function. > > > For instance when the array contains [0,1,2] I need to call > > > $(this).tablesorter({headers: {0: { sorter: false }, 1: { sorter: > > false }, 2: { sorter: false }}}); > > > and when the array contains [0,4,5,8] I need to call > > > $(this).tablesorter({headers: {0: { sorter: false }, 4: { sorter: > > false }, 5: { sorter: false }, 8: { sorter: false }}}); > > > How can I achieve so? > > > THANKS, I appreciate your help > > > Sig