Dynamic table problem with float values

Hello everyone!

I am wondering if someone could help me with my issue regarding dynamic tables. In my dynamic table, and before that in transactional data I have some field that are strings and some that are floats. I had to check treat empty as 0 for float values, otherwise it would report a mistake, or everything would turn gray.
So then in float fields instead of having empty field I have 0. That part makes me problems with dynamic tables - although all other fields are empty, those are filled with 0 and table does not hide.
image
I have tried making conditional to hide the table if those two values are equal 0, but it doesnt work if there are more details than 1.
for example
if (record.tables.kredit[“Iznos u docnji”] == 0 && record.tables.kredit[“A_Max Iznos u docnji”] == 0 ) {
results.attr(“data-conditional”, “”);
results.hide();
} else {
results.show();
}

Please, could someone help?
I would be grateful!

Hello @Ivan,

Select the fields (one at the time) that you want to not show when it is 0.
Refer to the image below to see what tabs need be selected:


Then click on the button next to the red arrow on the right of the previous image.
That will create a script instead for that field.

Look at the script below and adapt it to your need:
script

This is the result for me, as an example:

Hope that helps

Hello @Hamelj,

thank you for your reply.
I did as you suggested, but still table is visible, although those fields are empty.

.

I would have kept them as a string but formatting is important.
Any other idea?

My bad, I thought you wanted only to hide the 0 and show empty in their place.

Why can’t you leave them as string? You can always display 0 when you need to acually display them.

This way, your detail table is empty and you can use the following script to hide it:

if(!record.tables.detail)  results.hide();

The problem here is that even when all of the field values are empty, the detail table itself still seems to have a bunch of empty records. This means our built-in “hide when empty” feature for dynamic tables won’t work.

This is an unusual way to structure the input data and should ideally be solved on the data mapper side. If a record is empty you should not add it to the detail table.

If that is not an option you could consider adding a script that targets the table element and checks if all records in the detail table are empty:

const isRecordEmpty = rec => !rec["Iznos u docnji"] && !rec["A_Max Iznos u docnji"];
if (record.kredit.every(isRecordEmpty)) {
	results.hide();
}

Note: I tried to generalize this script using Object.values(rec.fields) but there seems to be a bug somewhere that prevents that from working.

I need a spesific format, data comes with “.” as decimal separator, but I need ", " as decimal and “.” as thousand separator. That is the problem.

Thank you all on your help! I have found the way.
I had to make a text script for each field of interest, make script like this:
results.each(function(index) {
var field, result = “”;

field = record.tables["kredit"][index].fields["Iznos rate"];
if (field !== 0) result += formatter.currencyNoSymbol(field);
 else result = "";
this.html(result);

});
and I had to delete data-field=“Iznos rate” in the source from the table element.
I posted this in case someone else needed it.
Thank you once more!