tags:

views:

340

answers:

1

I have an app written in XUL which contains a custom tree view that has many items. 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);
},
+2  A: 

Use the boxObject's scrollToRow() function.

If your tree is at this._tree,

this._tree.boxObject.scrollToRow(selectedIndex);
pc1oad1etter