Welcome Guest Search | Active Topics | Sign In | Register

slidemenu collapse/expand Options
quirtep
Posted: Friday, January 16, 2009 5:08:45 AM
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();
eo_support
Posted: Friday, January 16, 2009 6:39:02 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You can try

item.setSelected(true);

And see if that works.

Thanks!
quirtep
Posted: Friday, January 16, 2009 8:39:19 AM
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...
eo_support
Posted: Saturday, January 17, 2009 1:52:02 PM
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
quirtep
Posted: Saturday, January 17, 2009 2:50:29 PM
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.
eo_support
Posted: Saturday, January 17, 2009 3:18:53 PM
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.
quirtep
Posted: Sunday, January 18, 2009 2:53:25 AM
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...
eo_support
Posted: Sunday, January 18, 2009 4:22:05 AM
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!
quirtep
Posted: Sunday, January 18, 2009 4:28:25 AM
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.
quirtep
Posted: Sunday, January 25, 2009 7:17:21 AM
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...


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.