-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fundamentally broken internal data key mixup? #1524
Comments
Hi @DaneelTrevize! I think it's actually an issue of bad documentation since the The The headers: {
0: { parser: "select", sorter: "ipv4Address" }
...
} |
According to this doc page & my recollection of reviewing the code earlier, the parser value is indeed to save on having the nature of the data be auto-detected, and then the values that are generated by this choice of parser are naturally independant of how they are then sorted by the chosen sorter. Obviously you know how it was intended to be, yet this key name change fixed my problem (how else to efficiently define a cell's data as coming from an arbitrary attribute/data extension of the parent row, at the parsing & caching stage?), is consistent with the actual names of the parse->sort stages, and didn't break anything that I know of so far. I have several different use-cases where the value to sort a given column by is found via lookup into another data structure (e.g. of the arbitrary ranking of custom images/icons representing threat), and it seemed by design that the parser stage would be supplied with the custom function(s) to do this so that the values are cached, rather than regenerated every time every cell is compared & sorted against every other (i.e. the lookup performed by the sorting/comparator definition). |
Setting Yes, I know the naming is confusing (I blame @TheSin- 😜), but it was necessary to keep Do you still have a situation that can't be resolved by the methods available in this fork? I'd appreciate a demo showing the issue. |
Here's a fiddle for this issue and another that I don't have time left to fully explain today, but it's using the single key name modification as hosted on spectrefleet.com. If you keep the key mod (and it's for you to test the unforked version has the same behaviour as I was going to raise this as another issue but can't clearly explain it atm), you'll find TableSorter's miscounting the header indexes across colspans (the 3rd TH spans 2 TRs) according to its own |
Sorry for taking so long to get back to you. When I ran a diff on the spectrefleet.com tablesorter combined version and found this change: + parser = ts.getParserById( ts.getData( header, configHeaders, 'parser' ) );
- parser = ts.getParserById( ts.getData( header, configHeaders, 'sorter' ) );
noParser = ts.getData( header, configHeaders, 'parser' ) === 'false'; So it appears that the use of 4: {
parser: "distanceParser",
sorter: "digit",
sortInitialOrder: "asc"
}, I'm not sure why Anyway, I've modified the demo to remove 4: {
sorter: "distanceParser",
sortInitialOrder: "asc"
}, You can also minimize the code by setting a <thead>
<tr>
<th class="parser-false">Group</th>
<th>Σ</th>
<th colspan="2" class="sorter-typeParser sortInitialOrder-asc">Type</th>
<th>Σ</th>
<th class="sorter-distanceParser sortInitialOrder-asc">Closest</th>
<th class="sorter-distanceParser sortInitialOrder-asc">Median</th>
<th class="sorter-distanceParser sortInitialOrder-asc">Furthest</th>
</tr>
</thead> $("#test_table").tablesorter({
debug: true,
theme: "bootstrap",
widgets: ["uitheme"],
headerTemplate: "{content} {icon}",
sortInitialOrder: "desc",
sortRestart: true,
sortList: [[4, 1]]
}); |
I'm guessing this issue has been resolved, so I'm going to close it. If you continue to have problems, please feel free to continue the discussion in this thread. |
Allow me to equally apologise for basically abandoning this once it was working "well-enough". It seems your alterations to the demo fiddles have broken sorting for the last column. I've just tried using the latest 2.30.2 as-is (simplifying my headers back to trying sorter: rather than parser:, removing duplication where it shouldnt be required), but I'm still facing the problems of: |
Oh, I looked at the code again, and I think I found the issue... I'll update it in the master branch, so it won't be available until the next release. Updated demo - https://jsfiddle.net/Mottie/o7jctbmr/54/ (using master branch; rawgit may take a few minutes to update) |
Oops, had an issue with the docs... the next version is now available. |
I appreciate the very rapid response. I've had a chance to do some testing with 2.30.3, and while I've put it live, we're still seeing an issue with column header indexing. You too can now hopefully reproduce this result for that /d/1ds URL, by choosing "On & Off Grid Views", and considering the first (DPS) table being initialised. To test, the correct "Furthest" sorting should be 4, 15, 518, 1k. If we don't define a 7-indexed headers entry, we get this autodetection for the 6th https://i.imgur.com/SY9yVTD.png as text which sorts wrong. I tried to enable debugging just for core, but it seems to also log the uitheme widget ...which also might be indicating that widgets are being applied twice? https://i.imgur.com/9o2LLTR.png I'll try put together a jsfiddle of that DPS table from /d/1ds to simplify things... |
Ok, remove 1 of the 4 distanceParser assignments without breaking any of the 3 distance column sorts ;-) https://jsfiddle.net/o7jctbmr/56/ I'm beginning to suspect a mistake in the object literal syntax of
but that could be the flashbacks of PHP associative arrays & type coercing of numeric strings to integers talking... |
Ahh ok I see what you're saying now. The problem is the
To get around this, don't use the <thead>
<tr>
<th colspan="2" class="sorter-typeParser sortInitialOrder-asc">Type</th>
<th class="sorter-digit">Σ</th>
<th class="sorter-distanceParser sortInitialOrder-asc">Closest<br>km</th>
<th class="sorter-distanceParser sortInitialOrder-asc">Median<br>km</th>
<th class="sorter-distanceParser sortInitialOrder-asc">Furthest<br>km</th>
</tr>
</thead> I noticed that the HTML didn't include the wrapping |
I was aware of the header index vs data-column difference, that's what I've been trying to work with. Wouldn't your theory fail to explain why the 6th column My concern is that tablesorter appears to be inconsistently handling counting/indexing headers/columns, and that no documentation makes this clear. Thanks for the markup note. |
Yes, the This issue is related to #1362, and could be fixed, but then it would break all backwards compatibility. I already have this fix on my to-do list for the next major version (Abelt). |
tablesorter/dist/js/jquery.tablesorter.combined.js
Line 703 in 8703f25
Surely this should be using the key 'parser', not 'sorter'?
I have a simple instance where I've
$.tablesorter.addParser()
'd 2 new parsers, thenand it fails to use this parser, rather
debug: true
shows me it's auto-detecting on all headers/columns.I change the getData() key string in line703 of /dist/js/jquery.tablesorter.combined.js and it all works.
I can't quite believe it's as simple as it seems to me, because surely this would have been noticed before & caused many issues throughout..?
The text was updated successfully, but these errors were encountered: