Automate Offset

3 posts, 0 answers
  1. HSLaw
    HSLaw avatar
    158 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. Bryan
    Bryan avatar
    2 posts
    Member since:
    May 2012

    Posted 08 Mar 2018 in reply to Peter Link to this post

    I realise this is an old post, but can this be done client side, as that is where we configure what menu items are available to a user.

    Can't obviously see any reference to GroupSettings.OffsetY in the client side api documentation

Back to Top