Skip Navigation

[Resolved] table columns not sorting properly

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to sort a sortable table by column, but some columns are not sortable.

Solution: Some columns are not sortable, specifically those which display a value using a shortcode that requires an attribute. This functionality does not currently exist in the software, and should be requested as a new feature here: @https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

This support ticket is created 5 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 6 replies, has 3 voices.

Last updated by malagaS 5 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1212219

I am trying to: sort table by column headings

Link to a page where the issue can be seen: hidden link

I expected to see: sort alphabetically

Instead, I got: no sorting

#1212689
Screen Shot 2019-03-11 at 11.46.47 AM.png

Hi, sorry for the delayed response. I am investigating this now, and I assume this is the View you are referring to?
hidden link

Some types of content are not sortable in tables because of WordPress limitations. Specifically the post body is not a sortable field, so the 4th column "TASK" is not sortable. The Loop Wizard GUI will handle this automatically, but if you adjust the syntax manually in the Loop editor and add the "name" attribute to the corresponding wpv-heading shortcode, the column will appear sortable in the front-end. That's not recommended here, since the sorting algorithm will not be correct. I suggest you remove the "name" attribute from the wpv-heading shortcode for the TASK column.

Two of the columns are based on the post title, one is for the current post and the other is for a related post. In my local tests, this combination of columns seems to be broken. If I use the Loop Wizard GUI to set this up, the wpv-heading names are identical, resulting in unexpected results on the front-end. If I change the wpv-heading names for these two columns to use a unique identifier, sorting is just completely broken. I need to ask my 2nd tier team about this functionality, as it seems to be either a bug or a missing feature. I will let you know what I find out about those two post title columns.

The last two columns should sort by a custom date field. I opened up the Views debug window to see why these don't appear to be working. When I sorted by one of the custom date fields and refreshed the page, I could see that the MySQL query is not updated to reflect the sorting I chose (see the screenshot). I checked the syntax for these fields in the View and made a minor adjustment to fix this. I added "types-field-" to the heading name like this:

<th>[wpv-heading name="types-field-task-order-date"]ORDERED[/wpv-heading]</th>
<th>[wpv-heading name="types-field-task-due-date"]DUE[/wpv-heading]</th>

Now the two date columns appear to be sorting as expected. The Loop Wizard GUI should handle this automatically, so I'm not sure what happened here. Maybe the names were changed manually? At any rate, please confirm these two columns are now working as expected.

#1212808

thanks - the date columns are sorting now - that helps. but if i could get the 'client' column to sort that would take care of the critical need. the other columns aren't as important. i tried to change the view filter itself to sort by client and wasn't able to do that.

#1213260

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Christian is sick, let me add a note here.

It is not possible to add sortable column headings where the shortcode takes an attribute, e.g. an item attribute to specify that the field comes from a related post type.

It is a known issue for which we already have an internal ticket, but it has no traction as we do not have customers requesting support be added.

You can do that here: https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/.

That form goes directly to the product manager who decides development priorities.

#1213360

ok, I think I did the feature request - there is nothing to indicate my submission went through - nothing on the screen and no email. in any case, in the meantime, is there any workaround? is there a better way to do what i'm trying to do? because it's a pretty basic need...

#1213702

There's not a simple workaround in Views, unfortunately. You would have to manipulate the View filter using custom code and the wpv_filter_query API, then code some custom filters. On the other hand, it might be possible to integrate with a third-party table sorting tool to handle sorting on the front-end. wpDataTables offers a free lite version that can be driven by JSON code. With a bit of loop customization, you may be able to generate the necessary JSON structure.

#1214333

I got an email saying this is already slated for development. hopefully it will be soon! thanks.