Okay
  Public Ticket #1903605
Sortable invisible columns
Closed

Comments

  • Lee Johnstone started the conversation

    Dear WP-DataTables,
    I would like some advice please about sorting data by a certain column but not displaying it. I have done several tables on https://honour-roll.group.shef.ac.uk/

    but the main issue is the new style of table as seen on https://honour-roll.group.shef.ac.uk/individuals-new/

    The first three columns are 'Name', 'First Name' and 'Surname'. We only want the 'Name' to be displayed instead of all the first three but this column needs to be sortable by the 'Surname'.

    I can hide the other two columns and make the 'Surame' into the priority sortable column but this just means that all Dr., Mr. etc stay together in the 'Name' column. is there a way of linking the Name column to be sortable controlled by the invisible 'Surname' column?

    I have five tables to input and all will rely on the same formatting so once one is done, I can easily adapt the others.

    Thanks in advance,
    Lee

  •  2,572
    Aleksandar replied

    Hello Lee.

    Thank you for your purchase.

    If you want only the "Name" column to be visible, and the whole table to sort by "Surname" by default, even though that column is hidden - you can do that in column settings:

    6841921231.png

    And then click on the "eye" icon, so it's not display, but still sorted by it. You can also disable sorting for other columns, like I did here:

    4128139050.png

    So, the first column (Surname) is hidden and the table is sorted by it, and the other columns can't be sorted.

    The "Name" column will show its content the way it's entered, so I don't quite understand what you mean by this:

    I can hide the other two columns and make the 'Surame' into the priority sortable column but this just means that all Dr., Mr. etc stay together in the 'Name' column.

    I hope this helps.

    Best regards.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •   Lee Johnstone replied privately
  •   Aleksandar replied privately
  • Lee Johnstone replied

    Thank you again Aleksandar and sorry to bother you.

    In that case, is there a way to do any of the following. I have tried but cannot find a way around it.

    1. Create a link on the Name column so when it is clicked, it reloads the page. I can do this with a button on the page but wondered if it could be inserted in the header of 'Name"

    The search box is behaving strangely but there might be a fix.
    If you search for 'Jemma' it shows 'Jemma D Gurr' which is good.
    If you search for 'Gurr' it shows 'Jemma D Gurr' which is good. If you search for 'Jemma Gurr' it does not work.

    So I was wondering if either of the following could be done:
    1. Make sure the search finds all variables without need to be exact.
    2. Change the 'Search' label to "Search by first name or surname".

    If any of these can be done, I can then do it for all the other tables on the site.

    The current test example is at:
    https://honour-roll.group.shef.ac.uk/individual-donors-test/

    Thanks again,
    Lee



  •  2,572
    Aleksandar replied

    Hello Lee.

    For you to allow users to search for keywords out of order, you would need either to hook in the code that generates MySQL query, or change it directly in plugin core. Generally I’d not recommend that since it would prepare a ” LIKE ... OR LIKE ... ...” long query that would work slow even on small datasets.

    You can take a look in file wp-content/plugins/wpdatatables/source/class.wpdatatable.php around line 1548 where you can find logic for global search.

    As for changing the Search label to something else, please open wp-content/plugins/wpdatatables/source/class.wpdatatable.php around line 3283 find this:

    $obj->dataTableParams->oLanguage->sSearchPlaceholder = __('Search table', 'wpdatatables');

    and change 'Search table' with what you'd like it to display. That should do it.

    Best regards.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables