Hello.

How I can go through all the rows of the Table Records from JS. For example, this snippet returns false


SyntaxEditor Code Snippet

"<script>
var x = setInterval(function() {
    let table = $('#" + TestTimerTable.Id + "'); 
    if(table.rows[0] != null) 
    {
        alert('true')
    } else {
        alert('false');
    }
}, 1000);
</script>"

Hi Yuriy,

To get your table rows

var table = $('#" + TestTimerTable.Id + " tr')

To get the number of rows (including header row)

table.length

to get the table header row

table[0]

to get number of columns in the table

$('#" + TestTimeerTable.Id + " tr:nth-child(1) td').length

Regards,

Daniel

Replace this line

let table = $('#" + TestTimerTable.Id + "'); 

with

let table = document.getElementById('" + TestTimerTable.Id + "');


Daniël Kuhlmann wrote:

Hi Yuriy,

To get your table rows

var table = $('#" + TestTimerTable.Id + " tr')

To get the number of rows (including header row)

table.length

to get the table header row

table[0]

to get number of columns in the table

$('#" + TestTimeerTable.Id + " tr:nth-child(1) td').length

Regards,

Daniel


Can you answer me, please, how get custom field of table?

Hi  Yuriy,

I am not sure what you mean with "Can you answer me, please, how get custom field of table?"

Regards,

Daniel

Daniël Kuhlmann wrote:

Hi  Yuriy,

I am not sure what you mean with "Can you answer me, please, how get custom field of table?"

Regards,

Daniel

For example I have table:

11 12 13 14
21 22 23 24
31 32 33 34

How get record 23?


Solution

Yuriy Korevikov wrote:

Daniël Kuhlmann wrote:

Hi  Yuriy,

I am not sure what you mean with "Can you answer me, please, how get custom field of table?"

Regards,

Daniel

For example I have table:

11 12 13 14
21 22 23 24
31 32 33 34

How get field 23?



If yo use this

let table = document.getElementById('" + TestTimerTable.Id + "');

then you get the Dom


you can easily do 


table.rows[1].cells[2].innerText


Solution

Thank you!