How can I detect visible cells from "ScrollingTable" Node?


I am using scrollingtable example i.e. Scrolling Table. In this example i am able to draw a link with row which is not visible in table(link connects with last element of table which is not connected already).

But i want to draw a link only with that row of table which is visible to me/user.

Is Any way to achieve my required functionality?
Please help me to find a solution.

Best Regards,

You can use code similar to what is in the incrTableIndex function in ScrollingTable.js to determine the number of visible rows and use linking validation to ensure the row you’re connecting to is within the visible range.

function visibleOnly(fromnode, fromport, tonode, toport) {
  var table = tonode.findObject("TABLE");
  var tabh = table.actualBounds.height; // height of table
  var rowh = table.elt(table.topIndex).actualBounds.height;  // height of row
  var numVisibleRows = Math.max(1, Math.ceil(tabh / rowh) - 1);
  // make sure the port being connected is within the visible range
  for (var i = table.topIndex; i < table.topIndex + numVisibleRows; i++) {
    if ([i] === return true;
  return false;

myDiagram.toolManager.linkingTool.linkValidation = visibleOnly;
myDiagram.toolManager.relinkingTool.linkValidation = visibleOnly;

Thank you for solution