我一直在尝试使用sencha architect获取ext.js应用程序中树网格的滚动位置。最初我想在重新加载后保持滚动位置,这样当用户删除帖子时,它会在重新加载之后滚动回同一位置。我尝试过使用我搜索过的各种方法,但都不起作用。我目前正在测试一个java脚本超时函数,它在几秒钟后给我滚动位置,足够长的时间让我向下滚动并console.log这个位置,但它什么也没给我,当我进入dom并查看树视图对象时,我只显示零。我已经尝试了以下
1st: var newcompheight = comboboxeample.getHeight();
2nd: getScroll: function() {
var me = this,
dom = me.dom,
doc = document,
body = doc.body,
docElement = doc.documentElement,
left, top;
if (dom === doc || dom === body) {
// the scrollLeft/scrollTop may be either on the body or documentElement,
// depending on browser. It is possible to use window.pageXOffset/pageYOffset
// in most modern browsers but this complicates things when in rtl mode because
// pageXOffset does not always behave the same as scrollLeft when direction is
// rtl. (e.g. pageXOffset can be an offset from the right, while scrollLeft
// is offset from the left, one can be positive and the other negative, etc.)
// To avoid adding an extra layer of feature detection in rtl mode to deal with
// these differences, it's best just to always use scrollLeft/scrollTop
left = docElement.scrollLeft || (body ? body.scrollLeft : 0);
top = docElement.scrollTop || (body ? body.scrollTop : 0);
} else {
left = dom.scrollLeft;
top = dom.scrollTop;
}
return {
left: left,
top: top
};
3rd: var test = window.pageYOffset;
我还试图将Sencha architect中的keepwoll位置属性设置为true,以及我在谷歌上搜索过的其他内容,但都不起作用。如有任何帮助,我们将不胜感激。
使用此:
treeGrid.getEl().getScrollTop()