Expand my Community achievements bar.

SOLVED

Table help

Avatar

Level 2

Hi All,

I have a table(static or dynamic) with three rows. I need to get the no of rows in a table. I tried using instanceManager.count but it is giving me 1 instead of three.

I need to use some kind of function which i can use it for other tables as well.

Can anyone help me on this!

1 Accepted Solution

Avatar

Correct answer by
Level 9

Hi,

If your row names are like Row1,Row2,Row3 etc. If you use instanceManager.count will give you 1 as we have only one instance of Row1/2/3.

Instead you can use the following script.

var thisElement ;

    var nodeLength = Table1.nodes.length; // counts the total node length of the table

    var rowCount = 0;

    for (var i=0; i<nodeLength; i++) { // loop through the nodes

        thisElement = Table1.nodes.item(i) ;

   if (thisElement.className == "subform") { 

// as every row is a subform, it loops through all that and if it finds Row exists in the subform it increments the counter

     if(thisElement.name.indexOf("Row") != -1 ){

      rowCount ++;

    }

         

        }

    }

app.alert(rowCount );

For a dyanmic Row you can use instanceManager count.

Thanks,

Bibhu.

View solution in original post

1 Reply

Avatar

Correct answer by
Level 9

Hi,

If your row names are like Row1,Row2,Row3 etc. If you use instanceManager.count will give you 1 as we have only one instance of Row1/2/3.

Instead you can use the following script.

var thisElement ;

    var nodeLength = Table1.nodes.length; // counts the total node length of the table

    var rowCount = 0;

    for (var i=0; i<nodeLength; i++) { // loop through the nodes

        thisElement = Table1.nodes.item(i) ;

   if (thisElement.className == "subform") { 

// as every row is a subform, it loops through all that and if it finds Row exists in the subform it increments the counter

     if(thisElement.name.indexOf("Row") != -1 ){

      rowCount ++;

    }

         

        }

    }

app.alert(rowCount );

For a dyanmic Row you can use instanceManager count.

Thanks,

Bibhu.