I’ve done some reading and dataTables supports this.
click here
This explains the “what to do” but I need some help with the “How”. I understand the concepts of DOM model but the specifics of doing this inside a WordPress page or block or as pub options is a skill I want learn.
Can anyone help? Thanks.
Hi Charles,
The dom option allows you to change the order in which the filter and length items are shown, but it won’t make a difference when you put them on the same line. The reason is that the styling of both options uses a float. One item is floated right and one left. So changing the order will give you the same result.
You need to change the css. The simplest way is to add the following css to your WordPress theme in the additional css section:
.dataTables_wrapper .dataTables_filter {
float: left !important;
text-align: left !important;
}
.dataTables_wrapper .dataTables_length {
float: right !important;
}
Not a beauty, but it works. Note that this will restyle all DataTables on your website. If you want to change the styling for one specific DataTable only, use the id. You’d get something like this:
#wpda_sas_student_filter.dataTables_filter {
float: left;
text-align: left;
}
#wpda_sas_student_length.dataTables_length {
float: right;
}
You don’t need to add the !important property if you use the id as it is more specific, but you need to do it for every DataTable.
Hope this helps!
Best regards,
Peter
Thanks. The CSS help worked.
I still need a bit of guidance on getting the DOM model to work. I can’t seem to get it to work. Once it works I can experiment with different setup ups.
I have an embedded script in this page but it’s not working.
https://ottawa.ogs.on.ca/researching/indexes/library-catalog/
Search for “// inserted by Charles Godwin 2020-01-03” in the html
All help will be appreciated. Thanks
This is NOT urgent
Hi Charles,
I haven’t used the dom parameter before, but it works for me. Can you try to enter the following string in column “Table options (advanced)”: {"dom":"iptlfr"}
Where:
l – length changing input control
f – filtering input
t – The table!
i – Table information summary
p – pagination control
r – processing display element
Be aware that you need to write double quotes around your text. The example above switches the header and footer info. The default is: {“dom”:”lfrtip”}
Best regards,
Peter
Works like a charm. I used {"dom":"flirptip"}
Thanks again.