How do you force the XUL tree to scroll in code?
I have an application written in XUL that contains a custom tree view with many items. I have a button to remove the selected item, but my problem is that whenever that button is clicked, the tree scrolls to the very top. I tried to fix this by reselecting the item at the old index, but unfortunately this doesn't scroll the view. Is there a way that I can get the tree view, or not scroll up, or make it re-scroll back to its 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);
},
0
a source to share
1 answer
Use boxObject's scrollToRow () function .
If your tree is in this._tree,
this._tree.boxObject.scrollToRow(selectedIndex);
+3
a source to share