Note that there are some explanatory texts on larger screens.

plurals
  1. POMulti-select checkboxes with tablesorter
    text
    copied!<p>I have a Python script which generates an HTML table. The final column of the table contains checkboxes. I want to use the Shift key to select multiple checkboxes. So, I've incorporated <strong><a href="https://stackoverflow.com/a/659571/283650">this Javascript</a></strong>.</p> <p>However, I'm <em>sorting</em> the table columns after loading using <a href="http://tablesorter.com/docs/example-option-sort-list.html" rel="nofollow noreferrer">tablesorter</a> (and after calling the above Javascript). Furthermore, the user can also sort columns by clicking on column headers. This results in the wrong checkboxes being selected after the user uses Shift-click.</p> <p>So far I have tried:</p> <ul> <li>moving the <em>select multiple checkboxes</em> javascript to <em>after</em> the sorting (which seems logical to me), but then the sorting functionality does not work</li> <li>the other javascript answers to that question (<a href="https://stackoverflow.com/q/659508/283650">How can I shift-select multiple checkboxes like GMail?</a>) but then multi-select does not work</li> <li>other Googled code (<a href="https://gist.github.com/DelvarWorld/3784055" rel="nofollow noreferrer">like this</a>) - but again multi-select does not work</li> </ul> <p>The code:</p> <pre><code>&lt;script src='shift-click-select.js'&gt;&lt;/script&gt; &lt;script src='jquery-latest.js'&gt;&lt;/script&gt; &lt;script src='jquery.tablesorter.min.js'&gt;&lt;/script&gt; &lt;script&gt; //Javascript function to sort table "my_table" by default on first column (0,0) and then on second column (1) in ascending order (0). $(function() { $("#my_table").tablesorter({sortList:[[0,0],[1,0]]}); }); &lt;/script&gt; &lt;table id="my_table" class="tablesorter" border="0" cellpadding="0" cellspacing="1"&gt; &lt;td&gt;&lt;input type="checkbox" name="%s" class="chkbox" /&gt;&lt;/td&gt; ... &lt;/table&gt; </code></pre> <p>note: <a href="https://stackoverflow.com/a/659571/283650">shift-click-select.js is from answer mention above</a>.</p> <p>My guess is that I might need to re-number the checkboxes every time the table is resorted, but I'm hoping there is an easier way?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload