Welcome Guest Search | Active Topics | Sign In | Register

TreeView - Search/Expand/EnsureVisible Options
NathanG
Posted: Wednesday, December 19, 2007 8:39:33 PM
Rank: Newbie
Groups: Member

Joined: 12/19/2007
Posts: 2
Hi,

I have a rather large tree of around 1600 nodes and 4 level deep. It loads and renders quickly which is making this control very atttractive. Now I'm writing a search feature where a node will be expanded and scrolled into view upon being found. I having 2 problems.

The first problem I have is that the found node does not scroll into view properly. It seems to scroll to the parent of the found node. So if the node group is large and the found node is near the bottom is does not get scrolled into view.

The second problem is that I when do a second search or a search after I have manully expanded or selected nodes the tree view momentarily expands to the found node but then reverts back to the originally selected node. Is there a way to clear the memory of the TreeView control so it doesn't revert back to the first selected node?

The code I'm using is below.

Code: C#
protected void btn_find_Click( object sender, EventArgs e )
{
    EO.Web.NavigationItem[] foundItems = TreeView1.SearchItems( edt_find.Text,
        EO.Web.NavigationItemSearchOptions.SearchText | 
        EO.Web.NavigationItemSearchOptions.IgnoreCase );

    ( (EO.Web.TreeNode)foundItems[0] ).Selected = true;
    ( (EO.Web.TreeNode)foundItems[0] ).ExpandPath();
    ( (EO.Web.TreeNode)foundItems[0] ).EnsureVisible();
}


Hope someone can help!

Nathan
eo_support
Posted: Thursday, December 20, 2007 5:50:08 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
Hi Nathan,

Can you try to call our client side interface to expand/ensureVisible the item and see if it works fine? To try that you will need to do:

1. Render the Path of the found item to the client inside btn_find_Click;
2. Place a button on the client side (do not use body.onload) to trigger a client side JavaScript function;
3. Inside that JavaScript function to call our TreeView client side JavaScript interface to select/expand node;

Please let us know if that works.

Thanks
NathanG
Posted: Thursday, December 20, 2007 5:38:10 PM
Rank: Newbie
Groups: Member

Joined: 12/19/2007
Posts: 2
Thanks for the reply. I added a hidden field set it to the ItemID (searching by path didn't work client side). I also added a Show button, when pressed called ExpandPath, EnsureVisible and SetSelected (using the Select() method seemed to cause a postback).

It did work but sometimes required me to press the Show button twice to make it properly scroll into view.

Do you think I might be best re-binding the TreeView whenever the Find button is pressed?

Code: C#
HiddenField1.Value = foundItems[0].ItemID;


Code: JavaScript
function Show()
{
    var itemID = document.all["dnn$ctr365$ViewEMS_UnitSelector$HiddenField1"].value;
    var tree = eo_GetObject("TreeView1");
    var items = tree.searchItemsById( itemID );
    items[0].expandPath();
    items[0].ensureVisible();    
    items[0].setSelected(true);    
}
eo_support
Posted: Thursday, December 20, 2007 6:47:29 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
Hi Nathan,

Your code looks perfectly fine to me. Is it possible for you to create a reproducing sample for us so that we can reproduce the problem in our test environment? As soon as we reproduce it here, we should be able to either offer a fix or a workaround for you.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.