I have a WebDataGrid and in a javascript function that sellects next row. When the selected row passes the visible area of the grid the grid does not scroll up (down). How to force the grid to scroll to show the selected row? The selection mode is set to single row.
var grid = $find("wspltSearchRes_tmpl0_uwgResults");if (grid == null) return;var rows = grid.get_rows();var count = rows.get_length();if (count == 0) return;// TO UNSELECT A ROW// Remove first selected row from collectionvar currentSel = grid.get_behaviors().get_selection().get_selectedRows().getItem(0);if (currentSel != null) { var idx = currentSel.get_index(); grid.get_behaviors().get_selection().get_selectedRows().remove(currentSel); // Select row grid.get_behaviors().get_selection().get_selectedRows().add(grid.get_rows().get_row(idx + 1));
....
THANKS - it is just what I was looking for.
Hi,
Add this code in your JS after your last line. Also, be sure to add Activation to the behaviors collection.
var activation = grid.get_behaviors().get_activation();
var cell = grid.get_rows().get_row(idx + 1).get_cell(0);
activation.set_activeCell(cell);
regards,Dave
Please show me how to activate a cell having javascript grid object!!!
Selection is just visual to the user. You have two choices to scroll the row into view. The first would be to turn on activation and simply set the first cell of your new selected cell to be active. This will attempt to focus it and scroll it into view. The second would be to manually set the scroll top of the grid yourself in JS. Personally I would suggest the first approach. If you have difficulty, let us know.
regards,David Young