Following on from the resolution of my previous problem https://toolset.com/forums/topic/problems-trying-to-create-a-calculate-function/ I've reached my next stumbling block.
I'd like to create a view with sortable columns one of which I'd like to be "Commission Value". The problem I have is that potentially the column would be populated using two custom fields one based on commission percentage that is converted into a value, percentage-commission-value (see above thread) and one that is a fixed rate entered by the user, commission-fixed. Both equate to a commission fee that someone could potentially be paid so that's why I want them in the same column.
However from my understanding wpv-heading is limited to only sorting by one field which obviously doesn't work becuase a) when you do just have one field and then press sort you lose some of the results and b) even if all the results were still displayed they won't be displayed in numerical order which is kind of the point of the column.
Is there a way to sort a column by two fields at the same time or just by numerical value?
Many thanks as always, you guys rock!
Ed
Hello,
Yes, it is expected result:
wpv-heading is limited to only sorting by one field
If you are going to sort the result by multiple custom field, please try Sorting Controls, see our document:
https://toolset.com/documentation/user-guides/allowing-visitors-to-sort-the-front-end-results/
Screenshot:
enlace oculto
Yeah I thought of that but even if I use the sorting control it wont sort one entire column into value order if it is made up of two custom post types
Is there a way to implement something like this instead ......
enlace oculto
Please elaborate the new question with more details:
use the sorting control it wont sort one entire column into value order if it is made up of two custom post types
The "Sorting Controls" of Views plugin is able to sort the result by one or multiple custom fields in front-end, if there are posts from two post types, you just need to query posts of both post types, and make sure all posts have value in those sortby custom fields, since there is a limitation in WordPress class WP_Query:
https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
'meta_value' - Note that a 'meta_key=keyname' must also be present in the query
The "sorting controls" uses a system of sort by custom field 1 and then by then by custom field 2 so it will end up looking like image 1.
What I want it to look like is image 2.
Yes, you are right, I don't think it is possible to sort the result as your screenshot
enlace oculto
I suggest you add a feature request for it:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
Our developers will evaluate it.
No worries.
But is there a way to implement the suggested javascript from w3schools or something similar to it? I've tried to run the script inside the JS boxes when setting up the views but the loop editor and content template for the view don't seem to be talking to each other?
Don't worry about it. For anyone else who has this issue please just apply the following Javascript library .....
enlace oculto
It works a charm.