cancel
Showing results for 
Search instead for 
Did you mean: 

set focus on a tree node

Former Member
0 Kudos

Hello,

I'd like to set the focus on a tree node after loading the page.

I try to do it using a javascript as described on post

But this does not seem to work for tree nodes. Maybe it's because of tree nodes not being extended from class component?!

Thanks for your ideas,

regards

Bastian Distler

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member181879
Active Contributor
0 Kudos

Once a guru said: "life would be so much easier if one could see the source code". And it is true. With a few lines code you should be able to show us what you are trying to do.

"Maybe it's because of tree nodes not being extended from class component?" There is no real concept of class component in the browser. I wonder whether you are refering to CSS classes. Either way, be very careful in programming to close to the rendered HTML.

Also, I am not so sure about the real beenfit of focussing a node in the tree. Hmmm...

athavanraja
Active Contributor
0 Kudos

I too have this requirement as i have a tree on the left side and on the right side a table view is shown, based on the node selected. Though i have the selected node as the heading of the tableview, it would be nice to highlight the node selected (this feature is available in SAPGUI). Since this is not a urgent one, i havent done anything about it, but soon will be working on this.

Regards

Raja

0 Kudos

Hello Brian,

thanks for your reply.

The benefit of focusing a node in the tree is the following:

If a person only uses the keyboard to navigate (e.g. because of him/her being blind) expands a tree node, he expects the focus still being on the expanded tree node afterwards. But if a roundtrip to the server happens (because of a executed onClick-event) the focus after the reload is at the beginning of the page again. Thus the blind person hast to TAB through the whole page again until he reaches the tree node he has expanded.

I use the com.sapportals.htmlb.* package for the htmlb-elements.

Almost all elements are underclasses of com.sapportals.htmlb.Component, but Treenode is not.

I use a model to create tree nodes. TreeNodes are created like this in the Model:

  mComponentsNode = new TreeNode(COMP_NODE_ID);
  mComponentsNode.setComponent(new TextView(COMP_NODE_TEXT));
  mComponentsNode.setOnNodeClick(MODE_ON_CLICK_EVENT);
  mComponentsNode.setOnNodeExpand(TREE_NODE_EXPAND_EVENT);
  mComponentsNode.setOnNodeClose(TREE_NODE_CLOSE_EVENT);
  mComponentsNode.setTooltip(COMP_NODE_TOOLTIP);
  mComponentsNode.setOpen(true);
  mHomeNode.addChildNode(mComponentsNode);

In the JSP the tree is created like this:

  <hbj:tree id="configTree"
    title=""
    rootNode="configTree"
    rootNodeIsVisible="false">
  </tree>

Do you have any idea?

Thanks!

Regards,

Bastian

former_member181879
Active Contributor
0 Kudos

Aha, you are asking about the JSP version of the HTMLB library. This is a nearly complete different animal than the BSP version. In the beginning we copied all their tags. But over the years the two implementations have developed completely differently.

I now also understand you question better. Should you need this answer for BSP (nix mit J*), then get back so that we investigate some more.

However, in principle the HTMLB library (we are still refering to BSP!) does not contain any focus code, nor code to reset the focus after a roundtrip. So one might have to look at some custom development.

brian