Expand my Community achievements bar.

How to hide table with empty content using Javascript?

Avatar

Level 1

Hello!

I'm using Adobe LiveCylce Desinger integrated in SAP. I have a task to hide a database-table, if the table empty is.

Normmaly we can do following to check, whether the content empty is.

if (this.REMARK_TEXT.rawValue == null )

this.presence = "hidden";

else

this.presence = "visible";

The question is, how to check in Javascript, if a table empty is.

Many thanks in advance!

regards

longholiday

3 Replies

Avatar

Level 4

could try something like this:

function showOrHideTable(table){

     var isVisible = false;
    // gets the count of instance managers, event_initialize and row objects
    var rowCount = table.nodes.length;
    for(var i=0; i<rowCount; i++)
    {
        //get the class name
        var myTestNode = table.nodes.item(i).className;
        //ignores the instance managers and event_init
        if(myTestNode == "subform")
        {
            var innerCells = table.nodes.item(i).nodes;
            for(var j=0; j<innerCells.length; j++){
                //ignores non-input boxes
                if(innerCells.item(j).className == "field")
                {
                    //check value
                    if(innerCells.item(j).rawValue != ""))
                    {
                        isVisible = true;
                    }
                    else
                    {
                        //hide the row
                        table.nodes.item(i).presence = "hidden";
                    }
                }
            }
        }
    }
    //if any row has a value specified
    if(isVisible)
    {   
        table.presence = "visible";
    }
    //no value specified
    else
    {
        table.presence = "hidden";
    }

}

Avatar

Former Community Member

If you looked at the 1st cell in teh table and it was null woudl that be a good enough test?

Paul

Avatar

Level 4

I have a table currently that holds attributes from my data.  If the attributes aren't specified, the rows could be empty and skip around...so it could look something like:

Header 1
<Empty Row>
My Data
<empty Row>
My Data Again

So if I checked row1 for empty, that would be true, but I still have rows that I want to show.  So i just hide the row, and set a flag to determine if any rows are visible.  If there is 1 row with data, it's visible and therefore I show my table.