Okay
  Public Ticket #3718252
Question
Closed

Comments

  • Omar LMS started the conversation

    Can rows and columns be sorted using shortcode? For example [wpdatatable id=1 column_order="2,6,3,4,1,5" row_order="7,4,2,3,1,"]

  •  1,819
    Miloš replied

    Hi Omar,

    Sorry to disappoint you, but it is not possible to insert any sorting options into the table shortcode.

    For now, these are the functionalities we have available ( and additional workaround if you need to sort by multiple columns) when it comes to sorting :


    1. Regarding the "first, default" column -

     Each column has a “Default sorting column” switch in our Column settings/Sorting. 

    3693875442.png

    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 users 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. ( for example 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 

    6562202253.png

    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.


    3. You also asked about rearranging the column order :

    Right now, you can only rearrange columns in the table's back-end, by going into the column list, then you will see the icon for 'drag and drop' where you can drag a column with the mouse and then rearrange them.

    9766783426.png

    1603349875.png
    3952088665.png

    I hope that helps.

    Let me know if you have any additional questions.

    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

  • Omar LMS replied

    Thanks for your reply, I would have liked to be able to sort using the shortcode :'(

  •  1,819
    Miloš replied

    Hi Omar,

    Yes, it is like that for the time being. If you wish to see this in the future, you can make a development suggestion, but I can't promise an ETA if or when it might become possible.

    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.

    We also added this new developer's handbook, which can allow users with coding skills to make custom add-ons.

    Our developers will keep adding more custom hooks/examples there over time.


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

    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 use-case, we, unfortunately, don't have anything yet)

    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