Ensure the scroll location is retains in the query tool data grid if the user changes tab and then returns. Fixes #2875
parent
5f5c590ffd
commit
38f111d969
|
@ -917,7 +917,8 @@ define('tools.querytool', [
|
||||||
// fetch asynchronous
|
// fetch asynchronous
|
||||||
setTimeout(self.fetch_next.bind(self));
|
setTimeout(self.fetch_next.bind(self));
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
// Resize SlickGrid when window resize
|
// Resize SlickGrid when window resize
|
||||||
$(window).resize(function () {
|
$(window).resize(function () {
|
||||||
// Resize grid only when 'Data Output' panel is visible.
|
// Resize grid only when 'Data Output' panel is visible.
|
||||||
|
@ -1025,9 +1026,36 @@ define('tools.querytool', [
|
||||||
|
|
||||||
/* This function is responsible to render output grid */
|
/* This function is responsible to render output grid */
|
||||||
grid_resize: function (grid) {
|
grid_resize: function (grid) {
|
||||||
var h = $($('#editor-panel').find('.wcFrame')[1]).height() - 35;
|
var prev_height = $('#datagrid').height(),
|
||||||
$('#datagrid').css({'height': h + 'px'});
|
h = $($('#editor-panel').find('.wcFrame')[1]).height() - 35,
|
||||||
|
prev_viewport = grid.getViewport(),
|
||||||
|
prev_viewport_rows = grid.getRenderedRange(),
|
||||||
|
prev_cell = grid.getActiveCell();
|
||||||
|
|
||||||
|
// Apply css only if necessary, To avoid DOM operation
|
||||||
|
if (prev_height != h) {
|
||||||
|
$('#datagrid').css({'height': h + 'px'});
|
||||||
|
}
|
||||||
|
|
||||||
grid.resizeCanvas();
|
grid.resizeCanvas();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If already displaying from first row
|
||||||
|
if (prev_viewport.top == prev_viewport_rows.top) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// if user has scroll to the end/last row
|
||||||
|
else if (prev_viewport.bottom - 2 == prev_viewport_rows.bottom) {
|
||||||
|
grid.scrollRowIntoView(prev_viewport.bottom);
|
||||||
|
} else {
|
||||||
|
grid.scrollRowIntoView(prev_viewport.bottom - 2);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/* This function is responsible to create and render the
|
/* This function is responsible to create and render the
|
||||||
|
|
Loading…
Reference in New Issue