I'm using the great greystate XSLT helper (paginationhelper) (from a branch that allows for sorting), but I just noticed that the nodes are not sorted properly.
I don't know if this is just how xslt behaves, or if its a bug in the helper.
As far as I remember I have not made any changes that could have impacted this functionality (or if it ever has worked as expected...).
This is the order of which I expect the nodes to appear:
Text-10
Text-15
Text-25
...
And this is the order of which they are rendered:
Text-10
Text-100
Text-125
Text-15
Text-150
Text-200
Text-25
... and you get the point.
Yeah that's a little tricky - and let me just explain why: XSLT can sort either as text or number - your nodes will need to sort in two steps, first by the part before the dash, as text; then by the part after the dash, as number. So with a normal apply-templates or for-each, you'd do something like this:
The way I've implemented sorting in the helper is limited to full properties/attributes, and only a single sort is supported.
So basically, we'll need to customize your helper file to accomplish this, or...
The way I'd recommend would be to use the word $CUSTOM (or similar) in the sortBy parameter to trigger this, and then branch off in the preSort template and do the two sort statements - that way, you'll still have all the other features of the helper available.
I'll try a few things and might push a solution for this soon, provided I can get it working reasonably quick...
You're welcome - I've wanted to implement more advanced sorting for a while, but didn't really have any use cases or ideas as to how to do it — but describing the problem for you, trying to keep changes to the existing helper to a minimum, suddenly made me realize how to actually do it, so thanks for that, I guess :-)
Sort nodes properly (not like 1, 10, 2, 3, 33, 4 etc)
I'm using the great greystate XSLT helper (paginationhelper) (from a branch that allows for sorting), but I just noticed that the nodes are not sorted properly. I don't know if this is just how xslt behaves, or if its a bug in the helper.
As far as I remember I have not made any changes that could have impacted this functionality (or if it ever has worked as expected...).
This is the order of which I expect the nodes to appear: Text-10 Text-15 Text-25 ...
And this is the order of which they are rendered: Text-10 Text-100 Text-125 Text-15 Text-150 Text-200 Text-25 ... and you get the point.
This is how the pagination template is called:
Please let me know if you want a copy of the XML. But it should not be necessary since I'm just sorting on the @nodeName attribute.
Thanks.
Hi Stefan,
Yeah that's a little tricky - and let me just explain why: XSLT can sort either as text or number - your nodes will need to sort in two steps, first by the part before the dash, as text; then by the part after the dash, as number. So with a normal apply-templates or for-each, you'd do something like this:
The way I've implemented sorting in the helper is limited to full properties/attributes, and only a single sort is supported. So basically, we'll need to customize your helper file to accomplish this, or...
The way I'd recommend would be to use the word $CUSTOM (or similar) in the
sortBy
parameter to trigger this, and then branch off in thepreSort
template and do the two sort statements - that way, you'll still have all the other features of the helper available.I'll try a few things and might push a solution for this soon, provided I can get it working reasonably quick...
I've added a feature-request here: https://github.com/greystate/Greystate-XSLT-Helpers/issues/18
/Chriztian
Update: There's a new version of Pagination Helper available here that implements this — see the section in the README about how it works.
/Chriztian
Thank you very much for your nice explanation - and even more for the implementation! That was not something I would have expected ;)
But I'm sure that I'm not the only one finding the new extension useful.
Hi Stefan,
You're welcome - I've wanted to implement more advanced sorting for a while, but didn't really have any use cases or ideas as to how to do it — but describing the problem for you, trying to keep changes to the existing helper to a minimum, suddenly made me realize how to actually do it, so thanks for that, I guess :-)
/Chriztian
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.