我的页面上有一个jqGrid表格,里面有很多列,所以网格比浏览器窗口更宽,出现水平滚动条。如何在内嵌编辑时保持jqGrid的水平滚动位置?
问题是,当用户单击一行开始编辑时,浏览器框架会向左滚动,从而令用户感到困惑,甚至有时会隐藏选定的单元格。
我试过了我找到的方法here和here,但它们不适用于我 - 我可以检索当前的滚动位置,但我无法设置它。 细胞设定为columnsModel可编辑的,所以我得到滚动位置formatCell事件,并尝试设置滚动位置afterEditCell用下面的代码:
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;};
而且,这并不无论如何影响电网的行为 - 它滚动到最左边的位置。
还有其他方法可以实现吗? 非常感谢提前!