Delete empty data rows in table

I have a table that data populates from a server. For some reason the table is generating a empty row when there is no data available to populate into a row.

On the template side it is not set to generate a extra row if no data is available. Is there a script that can be placed so that the table does not generate a empty row if no data is available?

Thanks in advance for your help.

Yvette


Yvette Pennant


2 Answers

Voted Best Answer

As you are referring to a table in a XFA form, you can use the following script to remove the instances of empty rows in a table, supposing the repeatable row is called Row1. You can place the script in the layout:ready event of the table:

var n = Row1.instanceManager.count;
for(var i = n - 1; i >= 0; i--){
    var notEmpty = false;
    var oR = xfa.resolveNode("Row1[" + i + "]");
    var allChildElements = oR.nodes;
    var intNumElements = allChildElements.length;
        for (j = 0; j < intNumElements; j++) {
            var currentElement = allChildElements.item(j);
            if (currentElement.className == "field") {
                if(currentElement.rawValue != "" && currentElement.rawValue != null){
                    notEmpty = true;
                } 
            }
        }
    if(notEmpty == false){
        Row1.instanceManager.removeInstance(i);
    }       
}


By Almir R V Santos   

Thanks, Almir. the following script worked for my table/template:

if(Row1.Inter_valnId.isNull) this.presence = "hidden";


Yvette Pennant   


Please specify a reason: