3
votes

This is my problem.

I'm creating a dialog box (jQuery.dialog) and inside it there is this grid (https://github.com/mleibman/SlickGrid).

After loading data, I need to give the focus to the grid so the user can use the keyboard to view the data result without having to click inside the grid to select it.

But the function grid.getCanvasNode().focus() is causing all the content of the dialog to scroll up a little, but there is no need to since the canvas is already visible.

I think the source of the problem is the fact that this canvas is a very big div that contains all the rows of my result set (2000px) but only part of it is shown in the screen.

Is there some way to prevent this?

Thanks a lot!

1
perhaps there is a way to prevent this. Perhaps after we haven seen your code.Sven Bieder
The only way I found was changing the height of this canvas node, setting the focus and then changing the height for the previous value... not very classy...zedmartins

1 Answers

0
votes

Try using goToCell()

grid.gotoCell(row, cell, forceEdit)

Accepts a row integer and a cell integer, scrolling the view to the row where row is its row index, and cell is its cell index. Optionally accepts a forceEdit boolean which, if true, will attempt to initiate the edit dialogue for the field in the specified cell.

For eg:

grid.gotoCell(0, 0, false) // Will focus on first cell of first row