When using the front end editor option, is there a way to fetch a value from another row/column? If not, would the wpdatatables_before_create_columns hook be the best way to implement this?
Unfortunately something like this is not possible with the plugin build in features and the hook that you suggested will not do that.
I can give you some guide how you can achieve that:
You can get all of the data from the desired row on opening the edit modal.
To get the selected row you can use this code:
var row = $('#table_1 tr.selected').get(0);
to get some other row you can use this code
var row2 = $('#table_1 tr.selected').get(2);
So you can get the date like this for example
var data2 = wpDataTables['#table_1'].fnGetData(row2);
You can find row click event in the file
/wp-content/plugins/wpdatatables/assets/js/wpdatatables/wpdatatables.js around line 1141
/** * Select table row on click * @param e * @returns {boolean} */
var clickEvent = function (e) {
....
To get all the data from the clicked row
You can take a look at the example of that in file wpdatatables.js on line #957:
var row = $(tableDescription.selector + ' tr.selected').get(0);
var data = wpDataTables[tableDescription.tableId].fnGetData(row);
data variable will be an array with values of all row columns values (visible and hidden).
You will need to change the tableDescription.tableId because this will not be defined in your script.
In this case you will be able to get all of the data from the row and after that you can make what you desired.
Hi Bogdan - This is perfect! Thank you for taking the time to write this up. One more question if you don't mind - is there a way to save the results of formula columns to the database on a MySQL table? I have a table that will eventually have thousands of rows, and around 10 of the columns are formula columns, so I don't want the calculations to run every time the table is viewed (which will be a few times a day). I'd like to run the calculations once and save the results to the database to be easily viewed later on.
About the formula:
Unfortunately something like this is not possible with the plugin build in features at the moment.
The only thing that is saved in the database is settings for the formula columns but not the results.
From that settings which are saved the calculation is displaying in the tables.
Hello,
When using the front end editor option, is there a way to fetch a value from another row/column? If not, would the wpdatatables_before_create_columns hook be the best way to implement this?
Thanks
Alex
HI Alex,
Thank you for your purchase.
Unfortunately something like this is not possible with the plugin build in features and the hook that you suggested will not do that.
I can give you some guide how you can achieve that: You can get all of the data from the desired row on opening the edit modal.
To get the selected row you can use this code:
to get some other row you can use this code
So you can get the date like this for example
You can find row click event in the file
/wp-content/plugins/wpdatatables/assets/js/wpdatatables/wpdatatables.js around line 1141
To get all the data from the clicked row
You can take a look at the example of that in file wpdatatables.js on line #957:
data variable will be an array with values of all row columns values (visible and hidden). You will need to change the tableDescription.tableId because this will not be defined in your script.
In this case you will be able to get all of the data from the row and after that you can make what you desired.
Hope this can help you out. Best regards.
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 Bogdan - This is perfect! Thank you for taking the time to write this up. One more question if you don't mind - is there a way to save the results of formula columns to the database on a MySQL table? I have a table that will eventually have thousands of rows, and around 10 of the columns are formula columns, so I don't want the calculations to run every time the table is viewed (which will be a few times a day). I'd like to run the calculations once and save the results to the database to be easily viewed later on.
Thanks again
Alex
Hi Alex,
You are welcome.
About the formula:
Unfortunately something like this is not possible with the plugin build in features at the moment. The only thing that is saved in the database is settings for the formula columns but not the results.
From that settings which are saved the calculation is displaying in the tables.
Best regards.
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