Okay
  Public Ticket #3614421
Sorting/moving a row
Closed

Comments

  • Graham started the conversation

    Hi.

    We have a table sorted by wdt_ID from highest to lowest. The latest manually entered entry will appear at the top. However, one entry from August 2019 is in the correct location, ID 11, and should be 14. One column has html links.

    So, how do I fix this?

    When exporting to any of the tools, the links are removed, so exporting to Excel, fixing the table, and reimporting will not work.

    If there was a primary and secondary sort, I could sort on Year and then month!

    I have dug through the docs and cannot find any help.

    Thanks

    Graham

    8969216422.png


  •  1,689
    Miloš replied

    Hi Graham,

    I am not sure if I am understanding all the details of what you are trying to achieve for the sorting.


    1. if you wish to have the "sort by , then by another column" solution;

    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.


    Let me know if that solves the sorting issue?


    In case if you have HTML in some String Column and try to sort on it, as mentioned here;

    if you use HTML inside of string columns, sorting and filtering by this column can in some cases yield strange results, since it will also apply the sorting rules to the HTML itself.



    2. When it comes to exporting links :

    The “Include HTML” option will allow you to export columns that contain HTML (such as link, image, email, attachment, or HTML). They will be rendered as HTML in the exported files of the CSV, Excel, Print, and Copy options.

    This option is currently not available for the PDF export option.

    Please note that you should check this functionality on the front-end since if you use this option in the back-end the buttons in headers will be rendered as HTML as well.

    9854413785.png

    Let me know if you have any 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

  • Graham replied

    Hi Miloš

    I used option 2. I exported it as Excel and then modified the file, moving the row to the correct location (up 4 rows). I had to remove the HTML in the column headers before importing it into the same table again, replacing all rows, etc. 


    Thanks

  •  1,689
    Miloš replied

    Hi Graham,

    Yes - That can be a bit tedious if you have a lot of Headers when the “Include HTML” option is enabled;

    after exporting, we need to clear the HTML before importing the data again in the Plugin;

    For the time being, we can't change that, but we will do our best to make improvements in the future.


    I am glad to see you found a working solution for your use-case.

    If anything else comes up, please don't hesitate to reach out to us.

    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