Hi i need to have the table load by default to sort by Column B THEN by Column F.
This is because if Column B is the same for 2 rows i need them to show the higher value in Column F first in the sort order Eg Column B / Row 1 = 5 Column C / Row 1 = 12 Column B / Row 2 = 5 Column C / Row 2 = 15
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.
Hi i need to have the table load by default to sort by Column B THEN by Column F.
This is because if Column B is the same for 2 rows i need them to show the higher value in Column F first in the sort order
Eg
Column B / Row 1 = 5 Column C / Row 1 = 12
Column B / Row 2 = 5 Column C / Row 2 = 15
I need tos how Row 2 first.
Hi, Melina
Thanks for reaching out to us.
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:
It will create and show wpDataTable with multi column sorting, but you will not be able to use Sorting anymore for this table.
Kind Regards,
Miloš Jovanović
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia 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