joequery/Stupid-Table-Plugin

Doesn't sort properly...

Opened this issue · 4 comments

Hi there!

Can you please send over the HTML you used for your example? It's much easier to replicate from a gist or a JSfiddle than an image.

It can't handle colspan properly. Any table with colspan before the sortable column in any row will make it either crash (syntax error: "Cannot read property 'toString' / 'parseFloat' / 'parseInt' of undefined") or give wrong order.

I think it needs to fix the indexes in such a situation. In my case I just needed to keep the row with colspan at the end, so edited plugin code a bit, but still... as above.

I'm glad you were able to resolve the issue! What was the adjustment you made to the plugin?

I just added a "dontsort" class to my row with colspan, changed line 140 of plugin code to:

var trs = $table.children("tbody").children("tr").not('.dontsort');

and changed line 111, so it would prepend instead of appending (so my row with colspan would stay last after sorting):

$table.children("tbody").prepend(trs);

Please note, that it's only a solution for my case, when last row (containing colspan) may not be sorted... but has to stay at the end of the table then.

But I think the easiest way to fix the colspan sorting problem is to modify stupidtable_build() function a bit... so it would get proper elements from column... to something like in this project.