I have a jqGrid table on my page with a large number of columns, so the grid is wider than the browser window, a horizontal scrollbar appears.
The problem is that when the user clicks on a line to start editing, the browser frame scrolls to the left, which confuses the user and even sometimes hides the selected cell.
I tried the methods that I found here and here , but they do not work for me - I can restore the current scroll position, but I cannot set it. The cells are set as editable in the Modell columns, so I get the scroll position in the formatCell event and try to set the scroll position in afterEditCell with the following code:
afterEditCell: function(rowid, cellname, value, irow, icol) {
jQuery("#list").closest(".ui-jqgrid-bdiv").scrollLeft(scrollPosition);
window.scrollTo(scrollPosition,0);
if (window.pageXOffset) {window.pageXOffset = scrollPosition;};
if (document.body.parentElement) {document.body.parentElement.scrollLeft = scrollPosition;};
if (document.body) {document.body.scrollLeft = scrollPosition;};
And this does not affect the behavior of the grid in any way - it scrolls to the leftmost position.
Are there other ways to implement this? Thank you very much in advance!
source
share