I'm wondering if it's possible to dynamically create a table column during the rendering process?
My use case:
I have a table showing customers their packages.
I want customers to be able to link an invoice to a package by clicking on a button in a column(called "Upload invoice" for example) that leads them to a page where they can upload an invoice.
On that page I'd be running some PHP logic to read the URL parameters to know which package the invoice is being uploaded for and allow the customer to select and upload the invoice from the computer.
Obviously each package in the table would have a different ID, so I'd need to be able to read that information while the custom column is being appended to the table markup.
I don't want to be populating a "Upload invoice" column in the database with a redundant link that always only has a different "id" parameter. That's why I'm wondering if there's a way to add that column dynamically just before the rendering process of the table.
I think i understood the use-case, but i am not 100% sure, to be honest.
I will get a second opinion from a senior colleague at our 2nd Level Team, and we will advise you if we have a workaround solution to achieve your goal.
And of course, i will let you know if we need any further clarification from your end.
Actually, i just found an example from another case.
I am not sure if you need this exactly, but I will share it with you and let me know if that helps.
This user wanted to convert the values in one of the columns to a link that when clicked will run another query passing in the value clicked as a variable in MySQL and then display a second table with the new data.
-
This is how we first advised him, to construct the column by using CONCAT with our SQL Query based tables :
if there's a page on your website, that contains a string from a column (for example "page1" ), you can use CONCAT function, like:
SELECT column1,
CONCAT('<a href="www.yourwebsite.com/',yourTable.column2,'/">',yourTable.column2,'</a>') AS LINK
FROM yourTable
That would append "page1" found in column 2 to www.yourwebsite.com/, so the generated link would be www.yourwebsite.com/page1/, hyperlinked behind "page1" - entry in the cell.
-
The user then installed "Insert PHP Code Snippet", and this is what he said :
"Using that plugin, I created a shortcode that look like this:
I'm wondering if it's possible to dynamically create a table column during the rendering process?
My use case:
I have a table showing customers their packages.
I want customers to be able to link an invoice to a package by clicking on a button in a column(called "Upload invoice" for example) that leads them to a page where they can upload an invoice.
On that page I'd be running some PHP logic to read the URL parameters to know which package the invoice is being uploaded for and allow the customer to select and upload the invoice from the computer.
Obviously each package in the table would have a different ID, so I'd need to be able to read that information while the custom column is being appended to the table markup.
I don't want to be populating a "Upload invoice" column in the database with a redundant link that always only has a different "id" parameter. That's why I'm wondering if there's a way to add that column dynamically just before the rendering process of the table.
Hi, Uriahs
Thanks for reaching out to us
I think i understood the use-case, but i am not 100% sure, to be honest.
I will get a second opinion from a senior colleague at our 2nd Level Team, and we will advise you if we have a workaround solution to achieve your goal.
And of course, i will let you know if we need any further clarification from your end.
Thank you
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
Hi, Uriahs
Actually, i just found an example from another case.
I am not sure if you need this exactly, but I will share it with you and let me know if that helps.
This user wanted to convert the values in one of the columns to a link that when clicked will run another query passing in the value clicked as a variable in MySQL and then display a second table with the new data.
-
This is how we first advised him, to construct the column by using CONCAT with our SQL Query based tables :
if there's a page on your website, that contains a string from a column (for example "page1" ), you can use CONCAT function, like:
That would append "page1" found in column 2 to www.yourwebsite.com/, so the generated link would be www.yourwebsite.com/page1/, hyperlinked behind "page1" - entry in the cell.
-
The user then installed "Insert PHP Code Snippet", and this is what he said :
"Using that plugin, I created a shortcode that look like this:
Shortcode Name: GetReport
<?php echo do_shortcode('[wpdatatable id=4 var1="' . $_GET['ID'] . '"]'); echo do_shortcode('[wpdatatable id=3 var1="' . $_GET['ID'] . '"]'); ?>
Then in my page where the table is generated, I insert the shortcode below to display the tables using the ID param from the URL:
[xyz-ips snippet="GetReport"]
Hopes that can help the others looking for a solution".
-
Let me know if something like this might help, if you are trying to achieve something similar?
In the meantime, i will still ask our 2nd level Team for their opinion, as well.
Thank you
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
After thinking about this a bit more, I think I'd be able to get it accomplished on MySQL side using a view and temporary column.
Hi, Uriahs
That seems like a good plan as well.
We hope that you will accomplish the goal in either way, of course.
Let us know if you have any further questions about this, we will be here to assist. Thank you
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