我的頁面上有一個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;};
而且,這並不無論如何影響電網的行爲 - 它滾動到最左邊的位置。
還有其他方法可以實現嗎? 非常感謝提前!