Search code examples
iosswiftgridshinobi

Shonobi Data Grid scroll to a specific row


I have two grid let say grid a and grid b. Value of grid a is (1, 2, 3, 4, 5, ... 50) and in grid b (3, 5, 10, 25) .

I need when I click row with value 10 in grid b, then grid a will automatically scroll to row with value 10 too. Below code I have been try :

gridRoomStatus?.setContentOffset(CGPoint.init(x: 0, y: 0), animated: true)
self.gridRoomStatus?.reloadColumns(self.gridRoomStatus?.columns)

I have that code to make grid a go to the top when grid b is clicking. But it's still not solving my problem. I can't get a specific point for row with specific value. In UITableView there are tableView.rectForRow(at: indexPath) but I can't find similar function with that in Shinobi data Grid. How to do that?


Solution

  • Here I solved this problem, example :

    let rowHeight = 50
    let rowIndexToSnapTo = 20
    grid.setContentOffset(CGPoint(x: 0, y: rowHeight * rowIndexToSnapTo))