Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1840
Expand the menu and select a submenu-item client side (javascript)
posted

Hello,

since the expanding and selection of a submenu-item (my other post) in code behind (for ex. there are four levels and fourten nodes

A1000 -- A1100 -- A1110 -- A1111

|            |                        -- A1112

|            |                        -- A1113

|          -- A1200 -- A1210

|                        -- A1220

|                        -- A1230

|                        -- A1240

B1000 -- B1100

C1000

is on the way to a never ending story (no solution realy work), i am looking for an other solution. My problem: each node in my example should load some content in a textarea, if the user select the node (or item); so if i click on A1200 --> expand the submenu (A1210, ...), load the contetent for 'A1200' and don't close the menu (stay where you are). 

 

My first try was to sent the item-click to the server; in the item-value of the menu, i store the id of the record that i load via datareader and bind to the textarea.text. 

But there is a postback and the mneu is closed. I found no way to open in code behind!

So is there a way to open/expand the menu to a special node (A1200 ??) on page load?

Any better solution??

Thanks

Patric

  

Parents
  • 4493
    Verified Answer
    posted

    I am 100% sure what you are tyring achieve. Can't understand where is that text area - is it in the MenuItemTemplate or is it a separate control on the page. But the cleanest solution for me is to use the Client Side API for WebDataMenu. There is open method that each DataMenuItem has. So, when you load the content for your text area, you may want obtain an instance of WebDataMenuItem and then call its open method. This will cause the opening of the full path to where that item is  (regardless of how deep it is in the menu hierarchy). You could use the resolveItem(address) method of the WebDataMenu client object to get instance of the item you wish to open. Other way of obatining an instance of WebDataMenuItem that you need to open after loading the content for your textarea is to handle the client side Click event of the WebDataMenu. The handler shall have two parameters:

    function wdmItemClick(menu, eventArgs) { ... }

    The eventArgs has method "getItem()" which will give direct reference to the client object instance for the clicked item. You can set it to a globally scoped variable and just call the open() method of that globally scoped variable when your content loads.

    The main point is that you can't have menu staying opened when it loses focus. If your content loads fast enough, and you call open(), the menu may still stay openened. You can control to some extend the behavior. You may first want to set the CloseMenuOnClick property to false, then adjust the SubMenuClosingDelay to some higher value (value is in milli seconds) to keep the submenus opened for longer after losing focus (you want it to stay open during your content loading and after that).

     

    Hope this helps!

Reply Children