[英]How do you force a XUL tree to scroll in code?
I have an app written in XUL which contains a custom tree view that has many items. 我有一个用XUL编写的应用程序,其中包含具有许多项目的自定义树视图。 I've got a button that allows the selected item to be removed but my problem is that whenever this button is pressed, the tree gets scrolled all the way to the top.
我有一个按钮可以删除所选项目,但是我的问题是,每当按下此按钮时,树就会一直滚动到顶部。 I have tried to fix this by re-selecting the item at the old index, but unfortunately this does not scroll the view.
我试图通过重新选择旧索引处的项目来解决此问题,但不幸的是,这不会滚动视图。 Is there a way I can get the tree view to either not scroll to the top or force it to re-scroll back to the original position?
有没有一种方法可以使树视图不滚动到顶部或强制其重新滚动回原始位置?
My code looks something like this: 我的代码如下所示:
onRemoveNilSelection: function(event) {
var selectedIndex = this._tree.currentIndex;
this._treeView.removeItem(selectedIndex);
this._tree.view = this._treeView;
this._treeView.selection.select(selectedIndex);
},
Use the boxObject's scrollToRow() function . 使用boxObject的scrollToRow()函数 。
If your tree is at this._tree, 如果您的树位于this._tree,
this._tree.boxObject.scrollToRow(selectedIndex);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.