1 Reply Latest reply on Feb 28, 2008 8:02 PM by bpja

    AdvancedDataGrid expand to given item

      I'm happily using an AdvancedDataGrid to display Hierarchical data.

      What I now need to do is let the user type in a key value of an item they wish to find, and then have the datagrid expand the tree automatically and select the matching item.

      Finding the item in the underlying dataset isn't hard. However, I cannot figure out how to map this to whatever object the ADG.expandItem() and / or HDV.openNodes() calls require. Merely passing the data object to the expandItem() call doesn't do anything.

        • 1. Re: AdvancedDataGrid expand to given item
          bpja Level 1
          Turns out, the HeirarchicalData objects aren't as smart as I'd assumed.

          The answer involves implementing a depth-first search across the entire span, using a recursive iteration of any node that has children until you find the node you want. At that point, build an array of the nodes you've walked down into and pass the array to the gridview.dataProvider.openNodes property. Followup up with a gridview.selectedItem=item and scrollToIndex(gridview.selectedIndex) and you're golden.

          As to why gridview.expandItem(item,..) doesn't do this for you...I don't know.