简体   繁体   中英

RadContextMenu showing incorrect items when used in RadMultiPage

I have a RadContextMenu that is bound to a Radgrid. The context menu just allows the user to set the number of rows per page to show. When I use the Context menu on a RadMultipage that has several radgrids, the items being bound to the ContextMenu are incorrect.

For example the first RadContextMenu will have the following items added to it. (5,10,25,100,250,500)

Several other RadContextMenus on the Multipage will have this set of items added to it. (5,10,25,100)

When the page loads, every single ContextMenu on the different pages inside the Multipage has the first set of items added to it. The m_MaximumPaerRowsToDisplay property is being set correctly before OnInit is fired(I can step through and see that the other context menus are having the correct item set added).

The Items are being added to the ContextMenu during the OnInit event.

RadContextMenu1 = new RadContextMenu();
        RadMenuItem rmi = new RadMenuItem("Rows To Display".Localize());
        //there should always be at least a 5 rows added.
        rmi.Items.Add(new RadMenuItem("5"));
        if (m_MaximumPagerRowsToDisplay >= 10)
            rmi.Items.Add(new RadMenuItem("10"));
        if (m_MaximumPagerRowsToDisplay >= 25)
            rmi.Items.Add(new RadMenuItem("25"));
        if (m_MaximumPagerRowsToDisplay >= 50)
            rmi.Items.Add(new RadMenuItem("50"));
        if (m_MaximumPagerRowsToDisplay >= 100)
            rmi.Items.Add(new RadMenuItem("100"));
        if (m_MaximumPagerRowsToDisplay >= 250)
            rmi.Items.Add(new RadMenuItem("250"));
        if (m_MaximumPagerRowsToDisplay >= 500)
            rmi.Items.Add(new RadMenuItem("500"));
        if (m_MaximumPagerRowsToDisplay >= 1000)
            rmi.Items.Add(new RadMenuItem("1000"));

Any ideas?

I solved the issue. It wasn't related to the ContextMenu itself, it was related to the ContextNenu Event. The even being added to the page in javascript was only being added for one control, instead of each control having their own event. I added the ClientID of the control to the Event name and when registering the script and that fixed the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM