OL Learn

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();
    }
}