|
Rank: Advanced Member Groups: Member
Joined: 9/6/2007 Posts: 133
|
How can I collapse or expand slidemenu items client-side?
Edit - Note that the documentation seems to indicate that this will do it, but it doesn't seem to work:
item.collapseSubMenu();
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
You can try
item.setSelected(true);
And see if that works.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 9/6/2007 Posts: 133
|
That does not work. Note that I am actually trying to collapse, not expand, so I tried item.setSelected(false) - but that still doesn't make the slidemenu item collapse...
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, Please try the following code:
Code: JavaScript
function collapse_slidepane(index)
{
var slideMenu = eo_GetObject("SlideMenu1");
var item = SlideMenu1.getTopGroup().getItemByIndex(index);
if (item.getSelected())
item.click();
}
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 9/6/2007 Posts: 133
|
Alas, this doesn't quite do it. It's very close! It would work, except that the whole point is that I have an item in the menu with no subitems, and I want to make it so that other items collapse when it is clicked, but without having ExpandEmptyPane set to true.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
I would expect you to call the code on the other items that you wanted to collapse in that case. Basically now you have the code to test whether an item is expanded or not and expand or collapse any item at will, that's all you need.
|
|
Rank: Advanced Member Groups: Member
Joined: 9/6/2007 Posts: 133
|
OK - unless I'm missing something, it does not work because:
Assume I have a slide menu with items A,B,C.
A has no subitems, but B and C both do. B has subitems 1,2,3.
Assume 2 is selected, so B is expanded. Now, I click A, but A has no subitems. At this point, I want B to collapse, 2 to become unselected, and A to become selected (but not expanded since it has no subitems). I can check if B is selected, and use the item.Click() function, but it doesn't collapse the panel since a click on an expanded pane does not collapse it. I can use item.Click() on A, but it also has no affect on B since A has no subitems and so a click would not collapse other items...
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
I see what you mean. I don't think you can collapse the last expanded item when SingleExpand is set to true, either by code or by user. If you indeed want to do this, you would need to set the item's Expanded and Selected to false on the server side. You can use CallbackPanel or UpdatePanel to make it smoother, but I am not aware of any way to do it directly on the client side. Sorry about it!
|
|
Rank: Advanced Member Groups: Member
Joined: 9/6/2007 Posts: 133
|
No problem! I just wanted to make sure I wasn't missing something. I can definitely work around it. Thank you.
|
|
Rank: Advanced Member Groups: Member
Joined: 9/6/2007 Posts: 133
|
Just a FYI - but I discovered that trying to use item.click() in the SlideMenuClick function causes "too much recursion" because it essentially calls the SlideMenuClick function upon click which then causes a click which calls SlideMenuClick...
|
|