Hide rows in Detail Tables

I’ve started experimenting with Detail tables but need to hide an entire row when a field has a zero value.

I’ve looked at previous examples on the forum but cannot get the suggested solutions to work.

I currently have a condition being applied to the entire row, and the condition contains the following:

if (record.tables.detail[“subtotal”] == “0.00”) {
results.attr(“data-conditional”, “”);
results.hide();
} else {
results.show();
}

but this is not hiding any rows with “0.00” values. I’ve tried without quotes, I’ve even tried entering a field name that doesn’t even exist expecting a script error, but no error is reported.

If I highlight the condition, the table is being highlighted telling me the condition is correctly being applied to the detail rows.

As a suggestion, this might be an excellent topic to add to the How To page on the website.

What is the type for the field record.tables.detail[“subtotal”]?
Have you tried using the debug option for your script?
If the row could be any of those of the detail table, why aren’t using the following:

results.each(function(index){
    if (record.tables.detail[index].subtotal === “0.00”) {
        this.attr(“data-conditional”, “”);
        this.hide(); 
    } else {
        this.show();
    }
}

Hi,

Sorry I’m totally new to scripting this kind of thing, but what should I have in

this.attr(“data-conditional”, “”);

And how do I apply this to a row? And I guess this is created as a control script?

Hi @jbeal84,

I would add a class to the table cell containing the respective value. Subsequently create a script that selects that table cell and applies the desired logic.

Check the following articl belowe. The last section shows how to add color and background color to rows with negative values. This could be replaced with this.parent().hide();

Erik