I'm using the WP Data Tables shortcodes to display single cell data in elementor number counters which work perfectly unless I include a reference to a formula column. The issue is that number is displayed with a comma deliminator. There is the option to skip the thousands separator in a normal column, but not in the formulas. I'm using nested JSON file as a data source so I can't add the column to the source data.
is there any way of applying a conditional format or a format to the formula itself?
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, here is what you can try.
This needs to be done as custom work, which we do not provide support for.
You can try using the hook for the Formula column, and for the table that you need.
Just make sure to replace the table ID with the ID of the table that you need:
function removeSeparator ($formattedValue, $tableId){
if ($tableId == 1){
if (strpos($formattedValue,',') !== false) return str_replace(',','',$formattedValue);
}
return $formattedValue;
}
add_filter( 'wpdatatables_filter_formula_cell', 'removeSeparator', 10, 2 );
Add this to the functions.php of your current Theme ( or Child Theme) and let us know if that worked for you.
Wonder why this is not an option, and what makes you think that this option isnt nessesary for formular columns, but it is for all other type of columns.
The problem here, is, if the value should be 1100,00, it will with this code, return: 110000 - which is not correct.
This code here:
function removeSeparator($formattedValue, $tableId) { // Add your table id here. seperate with comma if you have more than one table where you want to apply this function if ($tableId == 1) { // Remove commas and periods that could be thousands separators $formattedValue = preg_replace('/\.(?=\d{3}(\D|$))/', '', $formattedValue); $formattedValue = preg_replace('/,(?=\d{3}(\D|$))/', '', $formattedValue);
// Convert the cleaned string to a float to standardize it to a number $floatValue = floatval($formattedValue);
// Determine if there's a significant decimal part if (fmod($floatValue, 1) >= 0.01) { // Format to two decimal places when there's a significant decimal, no thousands separator return number_format($floatValue, 2, ',', ''); } else { // Format as an integer, no thousands separator and no decimal places return number_format($floatValue, 0, ',', ''); } } return $formattedValue; }
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.
-
1. Firstly, in regards to the same subject as Tamsin has asked on this ticket, I will quote and reply to that part :
"Wonder why this is not an option, and what makes you think that this option isnt nessesary for formular columns, but it is for all other type of columns. "
We never said we think this option is not needed, it is simply not available at the moment for Formula columns.
We absolutely agree that this option would be great, but it is more difficult to add then it might seem, because our Formula Columns are not saved in an SQL database table, it is rather added by complex dynamic code by our developers and it is just dynamically shown in our Table via calculations.
So adding an option to skip the thousands separator for Formula Columns is going to take a lot of effort and time from our developers, and also a lot of testing from the QA Team before it gets added to the Plugin's core.
2. When it comes to your last reply, this is completely unrelated to the subject of the ticket, and I wrote a very long reply to your ticket about this subject.
This is about the custom function we sent you to change the delimiter of the exported CSV for our Table Tools.
Please check my reply on your ticket and let's proceed about that topic there.
When you have multiple questions or issues which are for different subjects/topics,
please open a new ticket for each subject, and we will help/advise more effectively.
In that way, issues and questions which are related to different subjects will be in separate tickets so other users or our support agents can find them easily.
Our policy is to have one issue or question per ticket for the reasons described already.
As far as i can see its totaly related to the dudes question below. The code you added below didnt work on our end, and made this site crash. This code i provided below return exactly what i needed, and what sounds lihe guy needed below.
If it can be done with a simple code as below, and dont understand the issue.
Also this formula question have absolutly nothing to do with the other custom made work around for column seperators.
I also created a ticket similar to this open ticket here, so when tried your code, and your plugin crashed, i felt free to adjust it. And my code works. Your dosent.
your customer support is almost always helpful, but i as paid customer, i think you have spend many many ,assages on apology for late answers. Nothing apoligize for.
Your support team is just to small for the amount of tickets created.
My code work, and skip the thousing separator, so i dont understand your answer.
You are right, now when i re-read all the details and took a closer/better look at the code edit you sent, I can see what you mean.
Thank you for sharing that with us.
I am just not a developer, so I completely misunderstood what the code does at first, thank you for clarifying it.
If you make a modification of our Plugin's code, we can not guarantee that it will work as expected, but I will certainly reach out to our developers about it.
They will review what you did, how you changed the code in question and I will let you know if they need any further clarification or details from your end and if they can advise if we plan to make a task to make a built-in improvement like that.
Thank you again for the clarification and for your patience.
I'm using the WP Data Tables shortcodes to display single cell data in elementor number counters which work perfectly unless I include a reference to a formula column. The issue is that number is displayed with a comma deliminator. There is the option to skip the thousands separator in a normal column, but not in the formulas. I'm using nested JSON file as a data source so I can't add the column to the source data.
is there any way of applying a conditional format or a format to the formula itself?
Many Thanks
Hi Tamsin,
Yes, for our Formula Columns, at the moment, as you pointed out, we do not have any 'skip thousand separator' option, as we do for the integers.
If you wish to see this as a built-in option in the future, you can suggest it to our developers- they will do their best to make a solution.
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, here is what you can try.
This needs to be done as custom work, which we do not provide support for.
You can try using the hook for the Formula column, and for the table that you need.
Just make sure to replace the table ID with the ID of the table that you need:
Add this to the functions.php of your current Theme ( or Child Theme) and let us know if that worked for you.
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
Exactly same issue we have!
Wonder why this is not an option, and what makes you think that this option isnt nessesary for formular columns, but it is for all other type of columns.
the previous code you didnt work. Instead it created a critical issue.
I updated the code, and now it ''works'':
function removeSeparator($formattedValue, $tableId) {
if ($tableId == 1) {
// Remove both commas and periods used as thousand separators
if (strpos($formattedValue, ',') !== false) {
$formattedValue = str_replace(',', '', $formattedValue);
}
if (strpos($formattedValue, '.') !== false) {
$formattedValue = str_replace('.', '', $formattedValue);
}
return $formattedValue;
}
return $formattedValue;
}
add_filter('wpdatatables_filter_formula_cell', 'removeSeparator', 10, 2);
The problem here, is, if the value should be 1100,00, it will with this code, return: 110000 - which is not correct.
This code here:
function removeSeparator($formattedValue, $tableId) {
// Add your table id here. seperate with comma if you have more than one table where you want to apply this function
if ($tableId == 1) {
// Remove commas and periods that could be thousands separators
$formattedValue = preg_replace('/\.(?=\d{3}(\D|$))/', '', $formattedValue);
$formattedValue = preg_replace('/,(?=\d{3}(\D|$))/', '', $formattedValue);
// Convert the cleaned string to a float to standardize it to a number
$floatValue = floatval($formattedValue);
// Determine if there's a significant decimal part
if (fmod($floatValue, 1) >= 0.01) {
// Format to two decimal places when there's a significant decimal, no thousands separator
return number_format($floatValue, 2, ',', '');
} else {
// Format as an integer, no thousands separator and no decimal places
return number_format($floatValue, 0, ',', '');
}
}
return $formattedValue;
}
add_filter('wpdatatables_filter_formula_cell', 'removeSeparator', 10, 2);
This code will return formular columns like: 1100,01, if value is greater than ,01. if its less than ,01, it will return '1100'
Hello Kim,
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.
-
1. Firstly, in regards to the same subject as Tamsin has asked on this ticket, I will quote and reply to that part :
"Wonder why this is not an option, and what makes you think that this option isnt nessesary for formular columns, but it is for all other type of columns. "
We never said we think this option is not needed, it is simply not available at the moment for Formula columns.
We absolutely agree that this option would be great, but it is more difficult to add then it might seem, because our Formula Columns are not saved in an SQL database table, it is rather added by complex dynamic code by our developers and it is just dynamically shown in our Table via calculations.
So adding an option to skip the thousands separator for Formula Columns is going to take a lot of effort and time from our developers, and also a lot of testing from the QA Team before it gets added to the Plugin's core.
2. When it comes to your last reply, this is completely unrelated to the subject of the ticket, and I wrote a very long reply to your ticket about this subject.
This is about the custom function we sent you to change the delimiter of the exported CSV for our Table Tools.
Please check my reply on your ticket and let's proceed about that topic there.
When you have multiple questions or issues which are for different subjects/topics,
please open a new ticket for each subject, and we will help/advise more effectively.
In that way, issues and questions which are related to different subjects will be in separate tickets so other users or our support agents can find them easily.
Our policy is to have one issue or question per ticket for the reasons described already.
Thank you for understanding.
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
As far as i can see its totaly related to the dudes question below. The code you added below didnt work on our end, and made this site crash. This code i provided below return exactly what i needed, and what sounds lihe guy needed below.
If it can be done with a simple code as below, and dont understand the issue.
Also this formula question have absolutly nothing to do with the other custom made work around for column seperators.
I also created a ticket similar to this open ticket here, so when tried your code, and your plugin crashed, i felt free to adjust it. And my code works. Your dosent.
your customer support is almost always helpful, but i as paid customer, i think you have spend many many ,assages on apology for late answers. Nothing apoligize for.
Your support team is just to small for the amount of tickets created.
My code work, and skip the thousing separator, so i dont understand your answer.
Hello Kim,
You are right, now when i re-read all the details and took a closer/better look at the code edit you sent, I can see what you mean.
Thank you for sharing that with us.
I am just not a developer, so I completely misunderstood what the code does at first, thank you for clarifying it.
If you make a modification of our Plugin's code, we can not guarantee that it will work as expected, but I will certainly reach out to our developers about it.
They will review what you did, how you changed the code in question and I will let you know if they need any further clarification or details from your end and if they can advise if we plan to make a task to make a built-in improvement like that.
Thank you again for the clarification and for your patience.
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