Welcome Guest Search | Active Topics | Sign In | Register

TreeView scroll Options
Arnold Bailey
Posted: Saturday, August 4, 2007 5:16:00 PM
Rank: Advanced Member
Groups: Member

Joined: 8/4/2007
Posts: 42
Is there a way to get the TreeView to automatically Scroll to keep the currently selected Node in view. My problem is that when using the keyboard to navigate, if you arrow down out of the view the treeview doesn't scroll up to keep your current node in view. You have to click the scrollbar to get it back and then if you want to go back to using the keyboard, click back into the treeview.

I've tried setting AutoScroll and EnableScrolling but they don' help. I guess and EnsureVisible() might be usefull if it can be called on the client side
eo_support
Posted: Saturday, August 4, 2007 5:41:43 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,095
Hi Arnold,

EnsureVisible indeed can be called on the client side:

http://www.essentialobjects.com/ViewDoc.aspx?t=JSDoc.Public.TreeNode.ensureVisible.html

You would call it on a client side TreeNode object. For example:

Code: JavaScript
var treeView = eo_GetObject("TreeView1");
var topGroup = treeView.getTopGroup();
var secondNode = topGroup.getItemByIndex(1);
secondNode.ensureVisible();


Please feel free to let us know if you have any other questions.

Thanks
Arnold Bailey
Posted: Sunday, August 5, 2007 6:35:05 AM
Rank: Advanced Member
Groups: Member

Joined: 8/4/2007
Posts: 42
OK now I would need an event that takes place on the client side when you navigate from one node to another using the keyboard so that as the new node is selected it calls EnsureVisible().

You have onClick and other events but I don't find anything for when the keyboard changes the highlighted node. Or a selected changed event.

The real purpose is to keep the currently highlighted node in view when the keyboard moves you down below the bottom of the view. Maybe this isn't the best way to do it. Component Arts does this automatically.

Also is there a way given a node buried in the tree to expand it and all the parent nodes above it.



eo_support wrote:
Hi Arnold,

EnsureVisible indeed can be called on the client side:

http://www.essentialobjects.com/ViewDoc.aspx?t=JSDoc.Public.TreeNode.ensureVisible.html

You would call it on a client side TreeNode object. For example:

Code: JavaScript
var treeView = eo_GetObject("TreeView1");
var topGroup = treeView.getTopGroup();
var secondNode = topGroup.getItemByIndex(1);
secondNode.ensureVisible();


Please feel free to let us know if you have any other questions.

Thanks


eo_support
Posted: Sunday, August 5, 2007 7:27:48 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,095
Hi Arnold,

I see. There doesn't see to be a way to do that now. Probably moving the selected node should actually fires the item click event. But either way, using keyboard to highlight an item should automatically move the highlighted item into view. So we will get that fixed and get an update build to you in a few days.

You can use the following code to expand a node and all its parent nodes:

Code: JavaScript
function expandPath(TreeNode node)
{
    //Expand all the parents first
    var parentGroup = node.getParentGroup();
    if (parentGroup != null)
    {
        var parentNode = parentGroup.getParentItem();
        if (parentNode != null)
            expandPath(parentNode);
    }

    //Expand ourself
    node.setExpanded(true);
}


Obviously it makes sense to have this function on the TreeNode object as well. So we will probably that as well.

Thanks for your feedback. Let us know if you have any more questions.

Thanks
Arnold Bailey
Posted: Sunday, August 5, 2007 8:01:41 AM
Rank: Advanced Member
Groups: Member

Joined: 8/4/2007
Posts: 42
Thanks for the really quick response. And as long as your taking requests.... :-)

Let me explain what I'm trying to do a little more throughly.

The app uses a treeView to display a tree of NNTP headers in a frame. When an item in the tree is selected the message for that header is displayed in another frame. This works fine with NavigateUrl and Targetwindow. In the Tree any messages that are New since some time are bolded so they are easy to spot. However since they are mostly embeded in the Tree you can't see them unless you can Expand down to that node and any other bolded nodes. I build the nodes dynamically on the server side. and at the point of bolding tried this.

if (bRecent)
{
rNode.Text = "<b>" + nodeText + "</b>";
ExpandAncestors(rNode);
rNode.EnsureVisible();
}

Where ExpandAncestors was

private void ExpandAncestors(EO.Web.TreeNode aNode)
{
if (aNode.ParentNode != null)
{
ExpandAncestors(aNode.ParentNode);
aNode.ParentNode.Expanded = true;
}
aNode.Expanded = true;
}

But this doesn't seem to work from the Server Side

Solving this and the scrolling problem and I think I'll have a winner.


eo_support wrote:
Hi Arnold,
I see. There doesn't see to be a way to do that now. Probably moving the selected node should actually fires the item click event. But either way, using keyboard to highlight an item should automatically move the highlighted item into view. So we will get that fixed and get an update build to you in a few days.
Arnold Bailey
Posted: Sunday, August 5, 2007 9:33:06 AM
Rank: Advanced Member
Groups: Member

Joined: 8/4/2007
Posts: 42
One other item on Keyboard handling. This is used by blind clients to navigate. I'm not sure you want to by default have the newly selected by keyboard fire the OnClick. It would be better to have the option of using the space bar or Ebter to fire the event. Then you can key rapidly down the tree and when you find the one you want hit space or Enter. Be nice to have a switch to Auto fire or by keyboard.

I note currently that if you hit Enter you get a script error at a getSubMenu() call in the client side script. Space bar does nothing.
eo_support
Posted: Sunday, August 5, 2007 9:59:19 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,095
Hi Arnold,

Thanks for the information. We will make sure to add the expand ancestor on both server and client side (and of course find out why the code you posted above does not work on the server side).

As for the client side OnClick, hitting enter and space bar to trigger OnClick is definitely the correct way to do. We will make sure it's implemented that way.

Thanks a lot for your valuable feedbacks!
Arnold Bailey
Posted: Sunday, August 5, 2007 10:43:29 AM
Rank: Advanced Member
Groups: Member

Joined: 8/4/2007
Posts: 42
Turned out the ServerSide expand code was my fault. It was a recursive routine and I called the ExpandAncestors before I actually added the node to the parent. Of course it couldn't set it. Duh! It works now.
eo_support
Posted: Tuesday, August 7, 2007 1:54:44 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,095
Hi Arnold,

We have posted a new build that address the auto scroll issue. It aslo added expandPath method on TreeNode method. Please see your private message for download location.

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.