Let me paraphrase that:
Is there a template where I can customize my table, which I made with a custom query?
Plugin Contributor
Kim L
(@kimmyx)
Hi @joehann,
You can further customize your table using the Advanced Settings section in your data table.
Please see this page for more information: Advanced Settings
Let us know if this helps! 😊
Sorry, that’s out of my league. I need the <td>s of my table to get some kind of individual distinction, i.e. an id, a class or a data-attribute which equals the content of the td. How can I achieve that? I have no clue about JSON and hardly any clue about Javascript.
ChatGPT made some code-suggestions based on Javascript, but they all don’t work with my tables, when I am using your plugin.
-
This reply was modified 3 years, 3 months ago by
Joehann.
-
This reply was modified 3 years, 3 months ago by
Joehann.
Hi Joehann,
All TD tags in a data table already have two classes:
– One class representing the column name (the red arrow in the screenshot added below)
– One class respresenting the data type (the green arrow in the screenshot added below)
https://ibb.co/fq1VvV
You can use these classes to group TD’s or access individual TD’s. This works with CSS and JavaScript.
Of course this only works within a row, but you can also access specific rows using the tr:nth-child(n) selector like this:
tr:nth-child(4) td.column_name {}
This works with CSS and JavaScript as well and allows you to access any TD in the table specifically.
Does this help? If not, can you share your requirements…
Thanks,
Peter
I know about these two classes and the option to use nth-child. My problem is that the order of rows changes dynamically, so it makes no sense for me to work with nth-child. I definetely need a way to tag every <td> with a class which equals the value/content of the <td>-tag.
My goal is to insert background-images into the <td>-tags of a certain column via CSS based on the class of the tds. So i.e. all tds with the class “horse” get the background-image of a horse.
Hi Joehann,
Thanks for the background info. That helps!
For your use case you can use the fnRowCallback option. You can find an example here:
https://wpdataaccess.com/docs/data-tables-advanced-features/advanced-settings/
Please scroll down to: revised javascript example
The example change the column color based on the column content. It’s almost similar to your use case. You just need to know a little javascript. Let us know if you need help with it.
Does this solve the issue?
Thanks,
Peter
Yes, it freaking did! I made it. Thank you!