Stupid-Table-Plugin icon indicating copy to clipboard operation
Stupid-Table-Plugin copied to clipboard

Doesn't sort properly...

Open FlashT opened this issue 7 years ago • 4 comments

http://193.70.114.83/wrong.png

FlashT avatar Feb 07 '18 17:02 FlashT

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.

joequery avatar Feb 07 '18 20:02 joequery

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.

FlashT avatar Feb 08 '18 09:02 FlashT

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

joequery avatar Feb 08 '18 11:02 joequery

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.

FlashT avatar Feb 08 '18 11:02 FlashT