Okay
  Public Ticket #3330427
Is it possible to sort by hidden columns?
Closed

Comments

  • Piotr started the conversation

    I need some functionality of wpDataTables plugin, but I don't find any information in documentation and I don't know if it is possible. Can you help me before I buy yours plugins (I need main plugin 'wpDataTables' and 2 or 3 addons to display data).

    Questions:

    1. Is it possible to create a custom buttons to sort data in table (not sorting using table columns)?
    2. Is it possible to to use a custom actions to sort table on hidden columns?

    I have in table 2 or 3 columns with custom data. This data is not allowed to display to users but a user must
    have the ability to sort the table to this criteria. Is it possible?


    Example:

    Table contains 3 columns: Name, Date of birth, City. I'll display only Name and City in front-end, but I have to sort table by 3 columns: Name, Date of birth, City.

    All this data together is not allowed to display (GDPR)!
    Is this possible to do?
    Can I use a custom function?
    Can you tell me which function I need?
    Can you send me information about yours actions and hooks and how to use it to build my custom sort buttons?

  •  1,819
    Miloš replied

    Hi, Piotr.

    I can see what you mean, thank you for elaborating about the use-case,

    it made it clear for us to understand what you need.

    I am truly sorry to disappoint you, but at this time, 

    with the current plugin's capabilities, we don't have a built-in solution to achieve this.

    As far as the built-in default sorting options go, i will share the informations, for example if you wanted to do a "sort by, then sort by additional columns" with tables :

    1. Regarding the "first, default" column - Each column has a “Default sorting column” switch. If you enable this switch for one of the columns, a selectbox will appear with options – “Ascending” and “Descending”, where you can choose the sorting direction . More about sorting with our plugin features you can read in our docs here - https://wpdatatables.com/documentation/table-features/sorting/


    2. - The only way you can sort the table by multiple columns with plugin's built-in functionality would be, 

    on the front-end, if you hold down SHIFT and click on the header of 2(or more) columns. ( in your case column B, then C)

    Basically, this means that, after the table loads, a page visitor has to do this, 

    click on the C column whilst holding SHIFT(added the clicked column as a secondary, tertiary etc ordering column)."

    But, in case you need this to be "already done before the page loads", there is a custom workaround, with an SQL Query;

    we are not suggesting to use ORDER BY at all in queries, because wpDataTables plugin is adding it dynamically based on what is set to be default sorting column.

    but if you disable the Sorting option for wpDataTable and create wpDataTable from SQL query e.g:

    SELECT * FROM `my_table` ORDER BY ColumnB ASC, ColumnC ASC

    It will create and show wpDataTable with multi column sorting, but you will not be able to use Sorting anymore for this table.

    -

    But, all of this works only with the visible column headers, i realise you need a custom option for hidden column sorting.



    If you wish to see a built-in option for that, you can suggest it to our developers - they will do their best to make a solution as soon as possible, but i can't promise an ETA.

    Please feel free to search on our suggestions page

     to see if someone may be already suggested this feature. If you can't see it, feel free to add your suggestion there,  and as more people vote, the feature will move higher on the priority list.

    You can certainly follow our changeLog page if you'd like ( it is also available in the plugin dashboard), where we state any changes/new features/bug fixes during updates;

    and our newsletter, so you're informed about new features, bug fixes, freebies, etc.

    -


    If you have coding skills and wish to try to make a custom solution now,

    you can check out our available hooks for Developers on this documentation and see if you can find any hook that might help to achieve this goal.

    Please be advised that custom solutions with hooks are not included in our support,

    but if you try to use any of the hooks/filters and if one of them does not behave as expected, you can reach out to us with sharing your code and explaining how you're trying to use your custom function,

    then we can ask our developers if they could advise ( if a small modification needs to be made / and if it does not go above what we can cover)

    You can also research resources such as Stack Overflow to see if any other user perhaps found a workaround.

    ( We do like to give examples for certain solutions, but for this specific use-case of making a custom button/function to allow front-end users to sort on hidden columns, we, unfortunately, don't have anything yet)

    -

    And i just wanted to point out that you can try wpDataTables before purchasing

     on our sandbox Demo sites ( you can find links for the main plugin Demo,  

    as well as add-on Demos, in my signature),

    and there is a 15-day money-back guarantee period, 

    so if you purchase the plugin, you can safely fully test it out, and if it doesn't fit your needs you can request and receive a refund in that period. ( same goes for all plugins and add-ons)

    Let me know if you have any additional questions. Thank you.


    Kind Regards, 

    Miloš Jovanović
    [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