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

[Solved] contextmenu with two lines per menu

2 Answers 101 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Markus
Top achievements
Rank 2
Markus asked on 23 Apr 2008, 12:46 PM
Hello everybody!
I have a simple contextmenu inside my radtree:
<contextmenus>
                                                <telerik:RadTreeViewContextMenu ID="cmAdministration"
                                                    runat="server" Skin="Outlook">
                                                    <Items>
                                                        <telerik:RadMenuItem ImageUrl="~/Img/New.png" PostBack="false" Value="NewGroup" meta:resourcekey="newGroup">
                                                            <groupsettings expanddirection="Auto" flow="Vertical" />
                                                        </telerik:RadMenuItem>
                                                        <telerik:RadMenuItem ImageUrl="~/Img/New.png" PostBack="false" Value="NewUser" meta:resourcekey="newUser">
                                                            <groupsettings expanddirection="Auto" flow="Vertical" />
                                                        </telerik:RadMenuItem>
                                                        <telerik:RadMenuItem ImageUrl="~/Img/Delete.png" PostBack="false" Value="DeleteGroup" meta:resourcekey="deleteGroup">
                                                            <groupsettings expanddirection="Auto" flow="Vertical" />
                                                        </telerik:RadMenuItem>
                                                        <telerik:RadMenuItem ImageUrl="~/Img/Delete.png" PostBack="false" Value="RemoveUser" meta:resourcekey="removeUser">
                                                            <groupsettings expanddirection="Auto" flow="Vertical" />
                                                        </telerik:RadMenuItem>
                                                        <telerik:RadMenuItem ImageUrl="~/Img/Delete.png" PostBack="false" Value="DeleteUser" meta:resourcekey="deleteUser">
                                                            <groupsettings expanddirection="Auto" flow="Vertical" />
                                                        </telerik:RadMenuItem>
                                                    </Items>
                                                    <expandanimation type="OutQuart" />
                                                    <collapseanimation duration="200" type="OutQuint" />
                                                    <defaultgroupsettings expanddirection="Auto" flow="Vertical" />
                                                </telerik:RadTreeViewContextMenu>
                                            </contextmenus>

The first item in the menu is  a single line, all other menuitems are two lines, in the first line there is the image, in the second one there is the text

kind regards

2 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 23 Apr 2008, 02:00 PM
Hello Markus,

This is indeed weird. I am afraid that there is not much I can say without first seeing your project files.

Can you isolate the problem in a small and running project and attach the files to a new support threa?

In the mean time I can suggest that you try the following:

  • Hook on the OnClientContextMenuShowing event of the treeview
  • In the event handler:

    function OnClientContextMenuShowing(sender, args)
    {
        var menu = args.get_menu();       
        var items = menu.get_items(); 
      
        var totalWidth = 0; 
        for (var i = 0; i < items.get_count(); i++)  
        { 
            totalWidth += items.getItem(i).get_element().offsetWidth; 
        } 
         
        menu.get_element().style.width = totalWidth + "px"; 
    }

If this does not help, please send us a small and runnin gproject to test locally and try to find another solution.

Regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Markus
Top achievements
Rank 2
answered on 23 May 2008, 11:24 AM
Unfortunately i had no time to isolate the problem.

Your javascript solution didn't work b/c offsetWidth returned 0!

I set the width attribute of the RadMenuItem Element manually which works fine in the meantime. But if the text of the menuitems becomes longer (through localization for example) the problem occurs again.

As I have some issues by now that needs to be solved via a support ticket, I'll try to find the time to build a sample project.

Kind regards,
Tags
TreeView
Asked by
Markus
Top achievements
Rank 2
Answers by
Nikolay
Telerik team
Markus
Top achievements
Rank 2
Share this question
or