[英]Scrolling a Div programatically using say Javascript
Hi I have a jqgrid which is embedded in a Div. 嗨,我有一个嵌入在Div中的jqgrid。 I am deleting records from the grid and reloading the grid using grid.Trigger('reload'). 我正在从网格中删除记录,并使用grid.Trigger('reload')重新加载网格。 The width of the grid is considerably high so it has a scroll bar. 网格的宽度很大,因此具有滚动条。 Now I scrolled through the end of the grid horizontally before deleting records. 现在,在删除记录之前,我水平滚动了网格的末尾。 Each time I delete the records and reload the grid, the column headers and their values are slightly misaligned. 每次删除记录并重新加载网格时,列标题及其值都会稍微对齐。 When I move the scroll bar back to original position or just move the scroll bar slightly they are aligned properly. 当我将滚动条移回原始位置或只是稍微移动滚动条时,它们将正确对齐。
So I thought its better to move the scroll bar to its inital position when the grid reloads. 因此,我认为在重新加载网格时将滚动条移动到其初始位置更好。 How can a scroll bar be programatically moved using javascript. 如何使用JavaScript以编程方式移动滚动条。 Or is there any other way to solve my problem? 还是有其他方法可以解决我的问题?
It seems to me that you have mostly a problem with wrong calculation of the width by jqGrid and not a problem with the horizontal scrolling. 在我看来,jqGrid对宽度的错误计算主要是您遇到的问题,而水平滚动没有问题。 Look at scripts which I posted in Correctly calling setGridWidth on a jqGrid inside a jQueryUI Dialog . 查看我在jQueryUI对话框内的jqGrid上正确调用setGridWidth上发布的脚本。 They are not perfect, but can fix calculation of the width of grid in the most situations. 它们不是完美的,但是可以在大多数情况下修正网格宽度的计算。 Moreover I recommend you to verify whether you change (probably indirect) default padding properties of <td>
elements. 此外,我建议您验证是否更改(可能是间接的) <td>
元素的默认填充属性。 If if is so it can be required to adjust cellLayout
option of jqGrid (see http://www.trirand.com/blog/?page_id=393/feature-request/celllayout/&value=cellLayout&type=1&include=1&search=1&ret=all ). 如果是这样,则可能需要调整cellLayout
选项(请参阅http://www.trirand.com/blog/?page_id=393/feature-request/celllayout/&value=cellLayout&type=1&include=1&search=1&ret=all )。
UPDATED
: One more tip: try to use the latest uncompressed version of jqGrid which you can downloaded from http://github.com/tonytomov/jqGrid . UPDATED
:另一个提示:尝试使用最新的jqGrid的未压缩版本,可以从http://github.com/tonytomov/jqGrid下载。 It has small fix in setGridWidth
(see http://www.trirand.com/blog/?page_id=393/bugs/some-bugfixes-for-3-6-5/ ). 它对setGridWidth
修正setGridWidth
(请参阅http://www.trirand.com/blog/?page_id=393/bugs/some-bugfixes-for-3-6-5/ )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.