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

How to enable scrolling for dynamically added submenu items for RadContextMenu

0 Answers 123 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Bryan
Top achievements
Rank 1
Bryan asked on 20 May 2016, 01:36 AM

Is there a way to add scrolling for dynamically added items to the sub menu? I've got many items loaded from ajax calls and dynamically added to the sub menu of my RadContextmenu on a RadGrid. Currently they are expanding beyond the boundaries of the viewport w/o any means to scroll to the bottom of them...

Here is my front end menu settings:

<telerik:RadContextMenu ID="contextMenu" runat="server" OnItemClick="contextMenu_ItemClick" OnClientItemClicking="onClientClicking" OnClientMouseOver="sb233loadtasks" 
    Skin="Metro"   EnableScreenBoundaryDetection="true" EnableAutoScroll="true" EnableRootItemScroll="true" DefaultGroupSettings-Height="500"  AutoScrollMinimumHeight="500" />

 

Below is JS to load and add the dynamic items to the sub menu:

function sb233loadtasks(menu, args)
        {
            var item=args.get_item();
 
// check if the target item is hovered over
            if (item.get_text().toLowerCase() == 'load task') {
                var icol = item.get_items(),timestamp=new Date().getTime();
                             
// show loading
                icol.getItem(0).set_visible(true);
 
            // remove items loaded from last time   
                for (var i = icol.get_count()-1 ; i >0 ; i--)
                    icol.removeAt(i);             
 
             // load the data from ajax call ...
 
                                var tasks = JSON.parse(data);
                                if (tasks instanceof Array && tasks.length) {
                                    menu.trackChanges();
                                    tasks.forEach(function (e) {
                                 
                      //add the item
                                            var sbsb = new Telerik.Web.UI.RadMenuItem();
                                            sbsb.set_text(e.taskname);
                                             
                                            icol.add(sbsb);
                                         
                                    });
                                    menu.commitChanges()
                                }

 

And adding conditionally other root items and the "load task" item to contain the sub menu in the back end, triggered upon page_load:

protected void SetupContextMenu(string ProjectID)
{          
    //Conditionally adding other static menu items...
      ...
     //Adding the item to contain the sub menu upon certain conditions
    RadMenuItem iETask = new RadMenuItem("Edit Task");
    iETask.Items.Add(new RadMenuItem(Utilities.Constants.loadingmsg));
    ...
}

 

I tried to set the default height both in the back end and on the menu tag, as well as disabling animations, removing autoscroll handler upon menu closure etc, per suggestions from other threads, so far all to no avail...

Any ideas?

 

No answers yet. Maybe you can help?

Tags
Menu
Asked by
Bryan
Top achievements
Rank 1
Share this question
or