How to hide table with empty content using Javascript? | Community
Skip to main content
January 19, 2010
Question

How to hide table with empty content using Javascript?

  • January 19, 2010
  • 3 replies
  • 14233 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

Level 4
January 19, 2010

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";
    }

}

January 19, 2010

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

Paul

Level 4
January 19, 2010

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.