I'm trying to set up a generic wpDataTable that displays contents of a single SQL table and dynamically changes the column headers from the %VAR2%,%VAR3%,... variables.
Since putting %VAR2% in the header name didn't work, I tried changing the SQL column names. This seems to work in edit mode and shows the default values of variables, but when I try display it from the page, the header names show the default placeholder value and the cells are empty.
This is an example SQL that I'm trying to use:
SELECT id,date_time,name,question1 AS '%VAR2%',question2 AS '%VAR3%',question3 AS '%VAR4%',question4 AS '%VAR5%' FROM bcc_surveys WHERE survey_id=%VAR1%
Is there a way to change the column headers dynamically?
Firstly, I would like to sincerely apologize for the delayed response as we have been experiencing an unusually high number of tickets. I am sorry that it has taken longer than usual to respond to your concern and your patience is highly appreciated.
We do not have any built-in way to achieve dynamically changing of the Header Names.
You can make a future development suggestion, but I can't say an ETA on it.
to see if someone may be already suggested this feature. If you can't see it, feel free to add your suggestion there, and as more people vote, the feature will move higher on the priority list.
You can certainly follow our changeLog page if you'd like ( it is also available in the plugin dashboard), where we state any changes/new features/bug fixes during updates;
and our newsletter, so you're informed about new features, bug fixes, freebies, etc.
-
If you have coding skills and wish to try to make a custom solution now,
I'm trying to set up a generic wpDataTable that displays contents of a single SQL table and dynamically changes the column headers from the %VAR2%,%VAR3%,... variables.
Since putting %VAR2% in the header name didn't work, I tried changing the SQL column names. This seems to work in edit mode and shows the default values of variables, but when I try display it from the page, the header names show the default placeholder value and the cells are empty.
This is an example SQL that I'm trying to use:
SELECT id,date_time,name,question1 AS '%VAR2%',question2 AS '%VAR3%',question3 AS '%VAR4%',question4 AS '%VAR5%'
FROM bcc_surveys WHERE survey_id=%VAR1%
Is there a way to change the column headers dynamically?
Hi Klemen,
Firstly, I would like to sincerely apologize for the delayed response as we have been experiencing an unusually high number of tickets. I am sorry that it has taken longer than usual to respond to your concern and your patience is highly appreciated.
We do not have any built-in way to achieve dynamically changing of the Header Names.
You can make a future development suggestion, but I can't say an ETA on it.
Please feel free to search on our suggestions page,
to see if someone may be already suggested this feature. If you can't see it, feel free to add your suggestion there, and as more people vote, the feature will move higher on the priority list.
You can certainly follow our changeLog page if you'd like ( it is also available in the plugin dashboard), where we state any changes/new features/bug fixes during updates;
and our newsletter, so you're informed about new features, bug fixes, freebies, etc.
-
If you have coding skills and wish to try to make a custom solution now,
you can check out our available hooks for Developers on this documentation and see if you can find any hook that might help.
Please be advised that custom solutions with hooks are not included in our support.
You can also research resources such as Stack Overflow to see if any other user perhaps found a workaround.
I found just one custom example which is not exactly the same as you described - but it is similar.
In this case, a User wanted to have a Dynamic Query which was variable via API or PHP.
This is what our developers advised that time :
You can take a look at our available filters for developers here ;
https://wpdatatables.com/documentation/information-for-developers/filters/
-
They pointed out this one :
wpdatatables_filter_mysql_query( $query, $tableId )
because you can use that to manipulate the Query.
There is also an option with Placeholders,
but combining these two or perhaps even just by using that hook/filter,
you might be able to achieve this use-case.
Please note that using hooks requires certain level of programming skills and included support refers only to advice.
I hope this helps.
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