简体   繁体   English

使用javascript / jquery(jqgrid)维护滚动条位置

[英]maintaining scroll bar position using javascript/jquery (jqgrid)

I have a problem with regards to maintaining the scroll position of my jqgrid . 我在保持jqgridscroll position方面有问题。

Here is the objective of my program: 这是我程序的目标:

  1. First, I click on the row. 首先,我单击该行。
  2. After clicking on the row, a form will pop-up. 单击该行后,将弹出一个表格。
  3. After updating record, the user will then close the form. 更新记录后,用户将关闭表单。
  4. The jqgrid will reload. jqgrid将重新加载。
  5. After the jqgrid reloads, it will select the "last selected item" 重新加载jqgrid之后,它将选择“最后选择的项目”

I have no problem with these steps (1-5) 这些步骤没有问题(1-5)

My problem is that if I have extensive rows for example 500 rows. 我的问题是,如果我有大量的行,例如500行。 It will display the scroll bars on the side of the jgrid. 它将在jgrid的侧面显示滚动条。

What I want to do is to maintain the scroll position of the scroll bars using Javascript or jQuery. 我想做的是使用Javascript或jQuery维护滚动条的滚动位置。 How do I do this? 我该怎么做呢?

I tried to use this, on loadcomplete event 我试图在loadcomplete事件上使用它

var scrollPosition = 0;
                scrollPosition = jQuery("#jqgrid").closest(".ui-jqgrid-bdiv").scrollTop(scrollPosition);
                jQuery("#jqgrid").closest(".ui-jqgrid-bdiv").scrollTop(scrollPosition);

but it doest give me the value of the scroll position 但是它没有给我滚动位置的值

See . 请参阅。 this fidle based on this article 该文章基于本文

<input type="submit" id="button"/>
<div id="div1"> </div>


$("#button").click(function() {
 $('html, body').animate({
              scrollTop: $("#div1").offset().top
 }, 2000);
 });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM