is there a way to programmatically change the column names of a table? We have a table with 24 columns that relate to a 2 year period. For example
Jan 2020 Feb 2020 ... Jan 2021 Feb 2021 ... etc. when the current year changes we need the column headings to change to Jan 2021 Feb 2021 ...... Jan 2022 Feb 2022, etc. With PHP code we can easily shift the row data but the column names have to be manually renamed
Something like this can't be done, but we can add a filter, so you can go into ..wp-content/plugins/wpdatatables/source/class.wpdatacolumn.php and on line 116 you will find this:
// $title current header //$origheader origin header of a column, if you need it //$columnObject column object, where all properties of that object are located, if you need them
function myFunction($title,$origheader,$columnObject){
// exapmle you will use your logic offcource
if ($title == 'columnName' ){
//your logic return $title; }
return
$title;
} add_filter('wpdatatables_filter_column_title', 'myFunction', 10, 3);
I have version 3.3 installed and tested the new hook for dynamically creating column headings and it works like a charm. 👍👍👍👍.
Great job!! Thanks so much.
We can now change a monthly property rental availability table from column headings like jancurr, febcurr ..... jannext, febnext.... to much more meaningful Jan 2021, Feb 2021 ... , Jan 2022, Feb 2022, etc.
is there a way to programmatically change the column names of a table? We have a table with 24 columns that relate to a 2 year period. For example
Jan 2020 Feb 2020 ... Jan 2021 Feb 2021 ... etc. when the current year changes we need the column headings to change to Jan 2021 Feb 2021 ...... Jan 2022 Feb 2022, etc. With PHP code we can easily shift the row data but the column names have to be manually renamed
Tedious at best
..
Hello hrvresort
I don't believe something like this is possible, but I forwarded the question to our lead developer.
As soon as he responds I'll get back to you.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
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
Hi again hrvresort
Something like this can't be done, but we can add a filter, so you can go into ..wp-content/plugins/wpdatatables/source/class.wpdatacolumn.php and on line 116 you will find this:
Replace it with this:
So, after that you can use this hook:
This will be added in our next update.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
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
I have version 3.3 installed and tested the new hook for dynamically creating column headings and it works like a charm. 👍👍👍👍.
Great job!! Thanks so much.
We can now change a monthly property rental availability table from column headings like jancurr, febcurr ..... jannext, febnext.... to much more meaningful Jan 2021, Feb 2021 ... , Jan 2022, Feb 2022, etc.
Great news hrvresort!
I'm glad to hear it works as intended.
If you have any further questions or issues, please feel free to open a new ticket, and we'll gladly help.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
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