diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js index 9a0c3de..df9e980 100644 --- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js +++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js @@ -914,7 +914,8 @@ define('tools.querytool', [ // fetch asynchronous setTimeout(self.fetch_next.bind(self)); } - }) + }); + // Resize SlickGrid when window resize $(window).resize(function () { // Resize grid only when 'Data Output' panel is visible. @@ -1022,9 +1023,31 @@ define('tools.querytool', [ /* This function is responsible to render output grid */ grid_resize: function (grid) { - var h = $($('#editor-panel').find('.wcFrame')[1]).height() - 35; - $('#datagrid').css({'height': h + 'px'}); + var prev_height = $('#datagrid').height(), + h = $($('#editor-panel').find('.wcFrame')[1]).height() - 35, + prev_viewport = grid.getViewport(), + prev_cell = grid.getActiveCell(); + + // Apply css only if necessary, To avoid DOM operation + if (prev_height != h) { + $('#datagrid').css({'height': h + 'px'}); + } + grid.resizeCanvas(); + + /* + * Lets scroll to previously displayed rows + * If there is an active cell from user then we have to go to that cell + */ + if(prev_cell) { + grid.scrollCellIntoView(prev_cell.row, prev_cell.cell); + } else { + /* + * Display approximate viewport but we do not have any exact cell information + * to display so we will start displaying from first column only + */ + grid.scrollRowIntoView(prev_viewport.bottom) + } }, /* This function is responsible to create and render the