question

Axel Kohonen avatar image
0 Likes"
Axel Kohonen asked Axel Kohonen commented

Is there a way to go to a certain row of a global table?

Hi,

When using large global tables it would be very nice to go to a certain row in the global table without having to scroll there. If I want to go to row 13450 e.g. it takes some time to scroll there. And when debugging code, it would be nice if I could get there using some kind of function call.

Is there a way to do this?

Thank you.

Kind regards,

Axel

global tablerack
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Phil BoBo avatar image
5 Likes"
Phil BoBo answered Axel Kohonen commented

You can use the scrollinfo() command to set the scroll position of a view.

The following code will scroll an active global table view to the row specified in the first line of the code.

It will go directly to the specified row if the table has less than 32767 rows (the precision limits of a Windows scroll bar) or close to that row if the table has more than 32767 rows.

  1. int goToRow = 13450;
  2.  
  3. treenode tableView = node("TableView", activedocumentnode());
  4. if (!objectexists(tableView))
  5. return 0;
  6.  
  7. double nMin = scrollinfo(tableView, 0, 1, 1);
  8. double nMax = scrollinfo(tableView, 0, 1, 2);
  9. double nPage = scrollinfo(tableView, 0, 1, 3);
  10. double nPos = scrollinfo(tableView, 0, 1, 4);
  11.  
  12. if (nMax < 32767) {
  13. scrollinfo(tableView, 1, 1, 4, goToRow - 1);
  14. repaintview(tableView);
  15. return 0;
  16. }
  17.  
  18. treenode tableDataNode = node(">viewfocus+", tableView);
  19. double totalRows = tableDataNode.as(Table).numRows;
  20. double pos = goToRow / totalRows * (nMax - nPage);
  21. scrollinfo(tableView, 1, 1, 4, pos);
  22. repaintview(tableView);
· 5
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.