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

EnableAutoScroll for RadContextmenu not working as expected (and documented)

7 Answers 160 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Paul Evers
Top achievements
Rank 2
Paul Evers asked on 25 Jul 2012, 03:05 PM
I have a RadContextMenu which I populate dynamically with menuitems.
I want to have the autoscroll enabled when the contextmenu becomes too large.

<telerik:RadContextMenu ID="contextmenuGraph" runat="server"
   OnClientItemClicked="menuitemGraphClicked" OnClientItemClicking="menuitemClicking"
   OnItemClick="contextmenuGraph_ItemClick" ExpandDelay="300"
   EnableAutoScroll="True">
   
</telerik:RadContextMenu>

According to the online-documentation the attribute EnableAutoScroll will enable a scroll if the menu is larger than the screen height.

RadMenu.EnableAutoScroll Property
RadMenu Class See Also Send Feedback
RadControls for ASP.NET AJAX
Gets or sets a value indicating if an automatic scroll is applied if the groups are larger then the screen height.

Namespace: Telerik.Web.UI
Assembly: Telerik.Web.UI (in Telerik.Web.UI.dll) Version: 2012.2.607.0 (2012.02.607.0)



This does not happen.

When I (as suggested in several forum-threads) add a height to the defaultgroupsettings the scroll does work.
<DefaultGroupSettings Height="400px" /> 

However, when I have a submenu with only 4 items this submenu will also be 400px, This of course is not what I want.

How do I get the behaviour that the scroll and height will only be applied when the height exceeds the maximum (which AUTO-scroll suggests) ?

Paul

7 Answers, 1 is accepted

Sort by
0
Paul Evers
Top achievements
Rank 2
answered on 26 Jul 2012, 07:54 AM
I have noticed that the EnableAutoScroll attribute for the headercontextmenu used in RadGrid has a default value true. In this contextmenu the autoscroll is working properly.
Why is this not working the same in RadContextMenu ???

Paul
0
Helen
Telerik team
answered on 27 Jul 2012, 08:29 AM
Hello Paul,

EnableAutoScroll doesn't work for RadContextMenu. If you want RadContextMenu to scroll, please use the GroupSettings-Height.


Regards,
Helen
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.
0
Paul Evers
Top achievements
Rank 2
answered on 27 Jul 2012, 08:37 AM
If I use the groupsettings-height the height of the contextmenu is set to this value, even when the menu has less menuitems than can be displayed in the configured height.
As the menuitems is determined by a model (I as a developer don't know how many items are to be displayed) this solution is not suitable.

In the header-contextmenu used in the RadGrid the option EnableAutoScroll does work. I assume that this contextmenu is the same as the RadContextmenu.
Why is this working in the RadGrid-header-contextmenu and not in the RadContextmenu?

Paul
0
Peter
Telerik team
answered on 31 Jul 2012, 08:45 AM
Hi Paul,

A simple and easy workaround that I can think of is to set the DefaultGroupSettings.Height property conditionally based on the number of root items:
protected void Page_Load(object sender, EventArgs e)
  {
      if (RadContextMenu1.Items.Count > 10)
      {
          RadContextMenu1.DefaultGroupSettings.Height = Unit.Pixel(400);
      }
  }

If you data bind the menu, then use its DataBound event instead of PageLoad.

All the best,
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.
0
Paul Evers
Top achievements
Rank 2
answered on 31 Jul 2012, 08:56 AM
With this solution the result is that submenus will also have this default height.

I did not get an answer to the question why the RadGrid-header-contextmenu works differently than the RadContextmenu.

My conclusion is that the RadContextmenu is not suitable for my purpose. I now have used RadMenu. In RadMenu the option EnableAutoScroll does work correctly.
In my opinion the fact that the option EnableAutoScroll does not work correctly in RadContextmenu is a bug.

Paul
0
Accepted
Peter
Telerik team
answered on 02 Aug 2012, 09:51 AM
Hi Paul,

Thank you for your feedback. I will log the issue and forward it to our developers to review it. You can monitor its status in the PITS - http://www.telerik.com/support/pits.aspx#/public/aspnet-ajax/12141.

Kind regards,
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.
0
Dave Wolf
Top achievements
Rank 1
Iron
answered on 25 Nov 2013, 06:48 PM
Stepping through the javascript, it seems that the problem with EnableAutoScroll and RadContextMenu exists because of the changing locations of a single RadContextMenu.

Regardless, with animations gone, you can force the context menu to forget the saved auto scroller information and rebuild it each time it is opened.

<telerik:RadContextMenu ID="RadContextMenu1" runat="server" EnableAutoScroll="true" OnClientItemClosing="removeAutoScroller">
    <ExpandAnimation Type="None" Duration="0" />
    <CollapseAnimation Type="None" Duration="0" />
</telerik:RadContextMenu>

<script type="text/javascript">
function removeAutoScroller(s, e) {
    s._openedItem._removeAutoScroll();
}
</script>

Tags
Menu
Asked by
Paul Evers
Top achievements
Rank 2
Answers by
Paul Evers
Top achievements
Rank 2
Helen
Telerik team
Peter
Telerik team
Dave Wolf
Top achievements
Rank 1
Iron
Share this question
or