Automate Offset

2 posts, 0 answers
  1. HSLaw
    HSLaw avatar
    153 posts
    Member since:
    Jan 2006

    Posted 22 Mar 2012 Link to this post

    Hi, 

    Referring to this example 
    http://demos.telerik.com/aspnet-ajax/menu/examples/functionality/offsetingthegroups/defaultcs.aspx 

    is there a way to automated the offset?

    I have a menu that is dynamically loaded and would like the expanded group to be aligned to the top always.
    Some of the menu has 1 line, 2 lines or 3 lines and I find it is a bit hard to do the offset calculation.
    Thanks.




  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 26 Mar 2012 Link to this post

    Hello,

    You can set the OffsetY property dynamically as a function of the Index. For example, try the following code:
    protected void Page_Load(object sender, EventArgs e)
       {
           foreach (RadMenuItem item in RadMenu1.Items)
           {
               item.GroupSettings.OffsetY = item.Index * -25;
           }
       }

    <telerik:RadMenu ID="RadMenu1" runat="server" Flow="Vertical">
           <Items>
               <telerik:RadMenuItem runat="server" Text="Root RadMenuItem1">
                   <Items>
                       <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 1">
                       </telerik:RadMenuItem>
                       <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 2">
                       </telerik:RadMenuItem>
                       <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 3">
                       </telerik:RadMenuItem>
                       <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 4">
                       </telerik:RadMenuItem>
                   </Items>
               </telerik:RadMenuItem>
               <telerik:RadMenuItem runat="server" Text="Root RadMenuItem2">
                   <Items>
                       <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 1">
                       </telerik:RadMenuItem>
                       <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 2">
                       </telerik:RadMenuItem>
                   </Items>
               </telerik:RadMenuItem>
               <telerik:RadMenuItem runat="server" Text="Root RadMenuItem3">
                   <Items>
                       <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 1">
                       </telerik:RadMenuItem>
                       <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 2">
                       </telerik:RadMenuItem>
                       <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 3">
                       </telerik:RadMenuItem>
                       <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 4">
                       </telerik:RadMenuItem>
                       <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 5">
                       </telerik:RadMenuItem>
                       <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 6">
                       </telerik:RadMenuItem>
                   </Items>
               </telerik:RadMenuItem>
               <telerik:RadMenuItem runat="server" Text="Root RadMenuItem4">
                   <Items>
                       <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 1">
                       </telerik:RadMenuItem>
                       <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 2">
                       </telerik:RadMenuItem>
                       <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 3">
                       </telerik:RadMenuItem>
                   </Items>
               </telerik:RadMenuItem>
           </Items>
       </telerik:RadMenu>


    Greetings,
    Peter
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top