Generating an RTL RadMenu from code

6 posts, 0 answers
  1. Kevin
    Kevin avatar
    27 posts
    Member since:
    Aug 2012

    Posted 16 Sep 2010 Link to this post

    Summary: How do I get the RadContextMenu to function in an RTL manner when generating it from code?

    I have seen many references on the forums regarding creating a RadMenu (RadContextMenu) by adding dir='rtl' to the <RadContextMenu> tab in your .aspx page.

    I assume that is how the control knows how to output the proper CSS classes, i.e:
    <div id="RadMenu1" class="RadMenu RadMenu_Vista RadMenu_rtl RadMenu_Vista_rtl" dir="rtl">
    My ContextMenu is being generated in code via something like:
    contextMenu = new RadContextMenu { EnableOverlay = true, ClickToOpen = true };

    I have tried using code like the following, but the '_rtl' CSS classes are not output:
    contextMenu.Attributes.Add("dir", "rtl");

    What is the proper way to do this?

    Thank you,
    Kevin
  2. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 17 Sep 2010 Link to this post

    Hi Kevin Kalitowski,

    You can set the RTL support via code-behind that way:

    RadContextMenu1.Attributes["dir"] = "rtl";

    where RadContextMenu1 is the ID of the RadContextMenu. Your way is not working as by doing this it seems you are trying to add a new Custom Attribute with name "dir" which is already done by default for the control.

    Hope this helps.

    Regards,
    Veronica Milcheva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Kevin
    Kevin avatar
    27 posts
    Member since:
    Aug 2012

    Posted 17 Sep 2010 Link to this post

    I changed the code as you mentioned, but the result is the same.

    contextMenu = new RadContextMenu { ID = this.ID + "rm", EnableOverlay = true, ClickToOpen = true }; 
    contextMenu.Attributes["dir"] = "rtl";

    After the '= new RadContextMenu()' is run there is NOT a ["dir"] item in the Attributes collection as was mentioned in your reply.  Once I do the .Attributes["dir"] = "rtl", the attribute is added to the collection.  However, whether I use Atributes.Add() or Attributes["dir"], the end result is the same.  The HTML that is output does not have the RTL css classes attached.

     

    <div class="RadMenu RadMenu_Vista RadMenu_Context RadMenu_Vista_Context ">

    Do you have any other suggestions?  Remember, that my RadContextMenu is NOT declared on an .aspx page, but is added to a Controls collection with some code similar to 'Controls.Add(contextMenu);'.

    Thank you,
    Kevin

  4. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 20 Sep 2010 Link to this post

    Hi Kevin Kalitowski,

    Where did you try to attach the context menu?

    I tried to add a "dir" attribute to a RadTreeViewContextMenu and both ways are working:

    RadContextMenu1.Attributes["dir"] = "rtl";

    or

    contextMenu.Attributes.Add("dir", "rtl");

    Could you please send me the full code so I can inspect it and help you?



    Best wishes,
    Veronica Milcheva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Kevin
    Kevin avatar
    27 posts
    Member since:
    Aug 2012

    Posted 20 Sep 2010 Link to this post

    Unfortunately that is much, much easier said than done.  I won't be able to send any code.

    Does it make any difference that I am using a RadContextMenu and not a RadTreeViewContextMenu as you mentioned, or that I am on the 2009.02.0701 release?

    Thank you,
    Kevin
  6. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 20 Sep 2010 Link to this post

    Hello Kevin Kalitowski,

    The RadTreeViewContextMenu is the context menu of the RadTreeView. RadContextMenu could be used by many other controls. That's why I am interested to what control you want to display a context menu. I am attaching my sample project for you to see the "RTL" support working on the RadTreeViewContextMenu. You can find it in the .zip file.

    I don't think that the version makes a difference for the RTL support. I've changed the Ticket Type to "Support" so you can attach your code.

    Regards,
    Veronica Milcheva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top