setting selected item in client-side?

This post has 3 replies

Top 75 Contributor
Posts: 58
SDE Posted: Tue May 9, 2006 @ 5:11 AM
Is it possible to set the Selected Item in Client-Side script?
Something like this maybe?

RootMenu.SelectedItem = RootMenu.FindItemById(lid)
RootMenu.Render()

But then something that works...
Top 10 Contributor
Posts: 806
jovan Posted: Wed May 10, 2006 @ 12:46 PM
This is currently not built in. I will add this feature to the list. It shouldn't be difficult to implement it, and there is a clear need for it. So I would expect to see it in future releases, perhaps as soon as SP3.

In the meantime, you will have to write some extra JavaScript code. For example:
function ClearSelectedItem(menu)
{
  var curItem = menu.SelectedItem;
  if (curItem == null)
  {
    return;
  }
  curItem.IsSelected = false;
  while (curItem.ParentItem != null)
  {
    curItem.ParentItem.IsChildSelected = false;
    curItem = curItem.ParentItem;
  }
  menu.SelectedItem = null;
}

function SetSelectedItem(menu,item)
{
  item.IsSelected = true;
  var curItem = item.ParentItem;
  while (curItem != null)
  {
    curItem.IsChildSelected = true;
    curItem = curItem.ParentItem;
  }
  menu.SelectedItem = item;
}

Please note this is a bit of custom-written code, and we cannot guarantee that it will work with future releases. So if your need is not urgent and/or you are concerned about having to maintain this bit of code, I would wait until a future version when the feature is properly implemented.
Not Ranked
Posts: 14
mission Posted: Fri Oct 21, 2011 @ 11:15 AM
I hate to resurect a 5+ year old post, but was this ever implemented? I don't see anything in the documentation that indicates that it has.
Top 10 Contributor
Posts: 6,149
stephen Posted: Mon Nov 7, 2011 @ 12:16 PM

It actually never was, unfortunately. I'll let the team know that this is something you'd like to see. 

Stephen Hatcher, Developer Support Manager
Page 1 of 1 (4 items)