Add items to menu dynamically

  1. #1

    Add items to menu dynamically

    Dear all,

    I am using the coolite gridpanel and added a listener on the event "RowContextMenu" to show a coolite menu.

    
    
    
    <RowContextMenu Handler="ShowRowContext(this, rowIndex, e,#{menuActions})" />//menuActions=id of the coolite menu
    
    
    
    var ShowRowContext = function(grid, rowIndex, e, contextmenu) {
    
    
    &#100;ocument.oncontextmenu = function() { return false }
    
    
    //select the rows
    
    
    grid.selModel.clearSelections(false);
    
    
    grid.selModel.selectRow(rowIndex, false);
    
    
    
    contextmenu.row = rowIndex;
    
    
    contextmenu.showAt(e.getPoint());
    
    
    }
    Since the items of the menu are different for each row, i had to add the items dynamically to the menu.
    So i called an ajax method that adds the items (this call was added at the line "grid.selModel.selectRow(rowIndex, false);" of the code above)
    The code below shows how the items where added using the ajax method.

    
    
    
    Coolite.Ext.Web.MenuItem item = null;
    
    
    for (int i = 0; i < dt.Rows.Count; i++)// dt is the data table that contains the actions to be added as items
    
    
    {
    
    
    try
    
    
    {
    
    
    item = new Coolite.Ext.Web.MenuItem();
    
    
    item.Text = dt.Rows[i]["ActionDisplayName"].ToString();
    
    
    item.ID = dt.Rows[i]["ActionID"].ToString();
    
    
    item.IconUrl = dt.Rows[i]["ActionIcon"].ToString();
    
    
    menuActions.Items.Add(item);
    
    
    menuActions.Items[i].Show();
    
    
    }
    
    
    catch (Exception)
    
    
    {
    
    
    }
    
    
    }
    The issue is that on the server side (ajax method), the menu.items.count is correct but on the client side, it's always zero and the items are not showing.

    I also tried to add a listener to the event BeforeShow of the menu, that calls the ajax method.but still did not work

    Thank you in advance for your help.
  2. #2

    RE: Add items to menu dynamically

    Hi,

    Dynamic control creation during AjaxEvent is not supporting at this moment. We are planning to add that feature to the 1.0 release
  3. #3

    RE: Add items to menu dynamically

    Thank you for your quick reply.

    Can I add the items to menu on the client side?
    If yes, can you please provide me with a small example?
    I noticed the client side method menu.Items.add but did not find any documentation on the arguments i should pass to this method.


    Thank you for your help.
  4. #4

    RE: Add items to menu dynamically

  5. #5

    issue with Adding menuitems dymically

    HI ,
    i am adding menuitems to menupanel dynamically and also adding ajaxevent .
    when click on that menuitem i am getting FOLLOWING exception. can you please help me. it is very urgent
    The control with ID 'PublisherInformation' not found
    Description: An unhandled exception occurred during the execution of the current web request.
    Exception Details: System.Web.HttpException: The control with ID 'PublisherInformation' not found
    Stack Trace: [HttpException (0x80004005): The control with ID 'PublisherInformation' not found]
    Coolite.Ext.Web.ScriptManager.RaisePostBackEvent(S tring eventArgument) +1061
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +13
    System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +175
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
  6. #6
    @kondareddy1984 - Please start a new forum thread with your question.
    Geoffrey McGill
    Founder

Similar Threads

  1. Replies: 0
    Last Post: Aug 09, 2012, 5:37 AM
  2. Replies: 8
    Last Post: Jul 29, 2012, 10:58 AM
  3. Replies: 2
    Last Post: May 21, 2012, 9:25 AM
  4. Replies: 11
    Last Post: Aug 30, 2010, 9:28 PM
  5. [CLOSED] [1.0] MVC sample west menu has no menu items
    By Inoventus in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Nov 24, 2009, 4:06 AM

Posting Permissions