I have a Repeatable Field Group ("Package") which contains a nested Repeatable Field Group ("Package Details"). I've created a view ("Pricing packages list") that outputs every Package Details record for every Package for the current post. I'm trying to sort the resulting list by one of the fields ("Number of Nights") by default, AND allow the user to control the sorting.
I have tried adding sorting controls to the "Pricing packages list" view, but when I do so, it stops any records from being output (I since reversed this change).
Is there any way to sort my output table of pricing packages?
Example: hidden link
Hi Eric,
Thank you for contacting us and I'd be happy to assist.
Based on what you've shared here and in the previous ticket ( https://toolset.com/forums/topic/view-returns-zero-results-after-adding-sorting-control/ ), I understand that the challenge here is that the list's layout is dependant on two views (nested in each other) and sorting controls are needed for the custom fields which are attached to the child view's repeating field group and not to the parent one.
The way WordPress post query works, if a custom field key is used to order the results, it will only fetch those results, which have any custom field record with that key attached. Any posts, without any record with that custom field key, will be ignored.
( this is why you were seeing 0 results earlier, as Minesh explained )
A better alternative way to offer front-end sorting functionality, in this case, would be to stop using Toolset View's own sorting feature and use a third-party table sorter script, which doesn't involve, database queries.
You'll first reconstruct the list so that it uses a table structure, making sure that fields that you'd like to use for sorting have their own column (e.g. nights, fishing days, price, etc).
After that, you can include any of the following third-party scripts, to include front-end table sorting:
hidden link
hidden link
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
Awesome, that makes perfect sense. Thanks for the insight and recommendation. It's too bad Toolset doesn't offer this functionality, but I can certainly use a front-end sorting script.