This is a migrated thread and some comments may be shown as answers.

Dynamic / Static Group Offset with images

1 Answer 51 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Fabio
Top achievements
Rank 1
Fabio asked on 10 Jul 2009, 12:34 PM
Ok I have a dynamic menu which consists of dynamically generated images. Since these images are generated dynamically there are no heights and widths associated with them.

The menu has two levels and I would like the child group to be displayed starting beneath the first item of the menu, not directly below its parent! The reason is that the child group will actually span too long if it's directly below its parent item.

I want it like this:

| PARENT 1 | PARENT 2 |
| CHILD 1 | CHILD 2 | CHILD 3 |

The following JavaScript works if I don't use Images, only text, but unfortunately it doesn't work with images!

Can anyone help me please

    function OnClientLoad(sender, args) { 
 
 
        var counter = 0
        var width = 0
        menu = sender
        var temp = 0
        for (var i = 0; i < menu.get_allItems().length; i++) { 
            width = 0
            var item = menu.get_allItems()[i]; 
            if (item.get_level() == 1) { 
                var parent1 = item.get_parent(); 
                var parent2 = parent1.get_parent(); 
                var items = parent2.get_items(); 
                for (var j = 0; items.getItem(j).get_text() != parent1.get_text(); j++) { 
                    widthwidth = width + items.getItem(j)._getWidth();    
                } 
                parent1.get_groupSettings().set_offsetX(0 - width); 
                } 
 
        } 
 
 
    } 

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 10 Jul 2009, 02:27 PM
Hi Fabio,

I think it does not work because the images may not be loaded during the OnClientLoad event. You could check if this is the case by inspecting if the offsetWidth property of item.get_imageElement() is not zero.
You can try executing that code when a menu item is being open. Use the OnClientItemOpening event to do so.

Regards,
Albert
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Menu
Asked by
Fabio
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or