Ruslan K · May 8, 2017

How select last added row in tablePane?

I want programmatically select last added row in tablePane. How I can do it?

0 308
Discussion (2)3
Log in or sign up to continue

Hi Ruslan,

You can use the rowCount property of the table to find the index of the last row. But keep in mind that it's a string rather than integer, since any number greater than the maximum rows will be "100+" for example. Try using the following javascript:

var table zen("your_tablepane_id")
var rowcount parseInt(table.rowCount)
if (!isNaN(rowcount)) tablepane.selectRow(rowcount)

This solution works when a global has autoincrement subscript. Then the most recent added row subscript always has greater value and after tblPane.executeQuery() new row is last in tablePane.

But my global's subscript is generated on runtime, it depends on input values. And after adding new record to global I call tblPane.executeQuery() and my new row is not last.  And I don't know how to find it for selecting.