Skip Navigation

[Gelöst] Some columns do not work with column sorting

This support ticket is created vor 5 Jahren. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Dieses Thema enthält 20 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Nigel vor 4 Jahren, 11 Monaten.

Assistiert von: Nigel.

Author
Artikel
#1400525

Hi,

I have created a table view with column sorting, however, some columns do not work correctly.
Watch the video that I attached: versteckter Link
versteckter Link

Thanks for your help.
Regards,

#1400853

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

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

I looked at your site and could see the issue, but I couldn't see why it was occurring.

I noticed that some of the columns are for fields from parent posts and I expect they will not work, filtering (or ordering) by fields of related posts isn't supported.

However, some of the other columns that I would expect to work are not, so I've taken a copy of the site.

I'll install that locally to do some more testing, and then I'll get back to you with my findings.

#1400907

Perfect, thank you very much Nigel.

#1401593

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

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

Screenshot 2019-12-06 at 13.22.07.png

I did some testing on the copy of your site.

The Printhead column doesn't work because different fields are used for the heading and for what is output for that column (see screenshot).

The Tipo Mandrill and Fabricante columns cannot work because they refer to a parent post, and you can only order by a post's own properties.

The other columns appear to work correctly.

#1401631

Yes. Now the "printhead" column works. 🙂
Thank you very much Nigel.
It is a pity that Toolset does not work with columns of related items, however, since it does not work, how can the sorting capacity for these columns be disabled?

Another issue. Could you help Waqar with the solution of a problem that is making me bitter on this ticket?
https://toolset.com/forums/topic/split-forms-edit-link-not-showing/
I need it urgently and your other support partners have not been able to solve it. 🙁

Thank you for all of your help.
Regards.

#1401647

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

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

I'm checking with my colleagues about whether it is possible to disable the column sorting for individual columns.

I can take a look at Waqar's ticket, but I won't be able to before Monday I'm afraid.

#1401653

Ok. Thanks Nigel.

#1402739
sort_tables.png

Nigel,
Have you been told how to disable the sort capacity of some columns?

Another thing, since you cannot order a field related column, I wanted to put the "id of the mandril" that must be stored directly in the custom type "impresoras". However I could not put it in a simple way, I could only put it in related mode, so it has the same problem as showing the name of the related field.
versteckter Link
Look at the screenshot.

Thanks for your help.
Regards,

#1402881

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

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

I'm still waiting for advice about whether it is possible to disable the sorting functionality on individual columns where sorting is not supported, when I get some further information I'll share it with you.

Sorting can only work on direct fields of the post type being displayed.

I'm not sure how you are adding the "id of the mandrill", but if it is using relationships sorting is not going to work, because it is not supported.

#1402887

Nigel,
How can I add the mandril id without having to use relationships?
Regards,

#1403103

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

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

You would need to add a custom field to store the ID.

You could manually add the ID values when saving the posts. If these are related and you have the post relationships section on the edit screen you should be able to see the ID, where you can then add it, though this would be cumbersome for many posts.

You could use the WordPress save_post hook to do it automatically, so that if saving a post of the relevant type, you used the Relationships API to get the ID of the connected post and then saved this as a custom field value, which you could then add as a column to the table.

My colleague in second tier identified what looks like a bug when the sortable table includes a column from a related post, and has escalated that to the developers for further investigation, so it may be that a solution could be provided for this, but I can't say just yet.

#1403123

Nigel,
Seriously? Would all that have to be done to get the id that is supposed to be contained within the field? (since otherwise I could not find the Toolset relationship)
This is very strong, if not, quite unfortunate. 🙁
Thanks.
Regards,

#1403793

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

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

The Post Reference field is effectively a relationship, and the data connecting the posts is stored in the relationship custom database tables, not standard post tables.

Hence the suggestion about "duplicating" the record by saving the fabricante post ID in a custom field of the impresora posts. If you wanted to do that I could help with the code that uses the save_post hook to do it automatically.

#1403821

I would appreciate it very much Nigel, since it sure would serve me that code for many other things. 🙂
Thanks for your help.

#1404557

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

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

OK, you can try this:

add_action( 'save_post', 'ts_mirror_parent', 10, 2 );
function ts_mirror_parent( $post_ID, $post ){

    $child_slug = 'impresora';
    $parent_slug = 'fabricante';
    $child_field = 'wpcf-parent-id';
    
    if ( $post->post_type == $child_slug ){

        $parent_id = toolset_get_related_post( $post_ID, $parent_slug );

        if ( $parent_id != 0 ){
            update_post_meta( $post_ID, $child_field, $parent_id );            
        }
    }
}

Check that the slugs are okay. This assumes you will save a Types custom field "parent-id" to store the related fabricante (the field is saved with a 'wpcf-' prefix in wp_postmeta).

Meanwhile, I'll let you know if there are any updates from the developers.