Dynamic / Static Group Offset with images

2 posts, 0 answers
  1. Fabio
    Fabio avatar
    2 posts
    Member since:
    Mar 2009

    Posted 10 Jul 2009 Link to this post

    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); 
                    } 
     
            } 
     
     
        } 

  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 10 Jul 2009 Link to this post

    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.
Back to Top