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

right click on a grid row to get menu list

4 Answers 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jas
Top achievements
Rank 1
Jas asked on 04 Dec 2008, 06:44 AM
I want to see a menu list when i right click on a row in RadGrid.
Can anyone tell me what is the best way to implement this i.e

1. how to track right click even on a radgrid row
2. open up a menu on right click.

Also, does telerik have a menu suitable for this scenario.
My menu would have some items one after the other

3. I need to click on various items on this menu and open a new url

Please help me out with these three items

Thanks

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 04 Dec 2008, 07:23 AM
Hi Jas,

Here is an online demo which demostrates the desired scenario. Go through it and see if it helps.
AJAX-enabled context menu

Thanks
Princy.
0
Jas
Top achievements
Rank 1
answered on 05 Dec 2008, 12:39 AM
Hi Princy,

I am facing the following problems with RadMenu

1. Whenever I load the page which has RadMenu in it, i get the following javascript error seen in the status bar of the page
   Line: 2829
   Char: 23
   Error: Sys.ArgumentException: Value must not be null for controls and behaviors.
   Parameter name: element
Don't know if it is really adding RadMenu to the viewstate or not or something else. Also, line 2829 doesn't exist.

2. telerik:RadContextMenu ID="RadMenu1" runat="server" Skin="Vista"  OnClientItemClicked="OnClientItemClickedHandler">          
        </telerik:RadContextMenu>
   function OnClientItemClickedHandler(sender, eventArgs)
   {
       alert(eventArgs.Item.Text);
   }

eventArgs.Item.Text is undefined.
Infact, I eve tried

 var menu1 = <%=RadMenu1.ClientID %>;
        alert (menu1.Items.length);

but Items.length is null.

So in short, i am not able to access any client side property of RadMenu.

---------------------------------How i Populate my items is as follows---------------------

///Following is the RadGrid in which right click on all rows should open the RadMenu

<telerik:RadGrid
                    ID="RadGridDataReport"
                    runat="server"                   
                    Skin="Office2007"
                    GridLines="Both"
                   
                    OnNeedDataSource= "RadGridDataReport_NeedDataSource"                                       
                    AllowAutomaticInserts="false"                    
                    AllowMultiRowSelection="true"
                     AllowSorting="true"
                    Width="100%" >
                    <MasterTableView
                        AutoGenerateColumns="True"
                        AllowMultiColumnSorting="True"
                        GridLines="None"                       
                        CellPadding="2"
                         AllowSorting="true"                        
                        TableLayout="Fixed">
                        <NoRecordsTemplate>
                            <div>There is no data available.</div>
                        </NoRecordsTemplate>                                                                 
                    </MasterTableView>
                    <ClientSettings>
                        <ClientEvents OnRowContextMenu="RowContextMenu"></ClientEvents>
                        <Selecting AllowRowSelect="true" />                   
                        <Scrolling AllowScroll="True" UseStaticHeaders="true" />
                    </ClientSettings>                                       
                  </telerik:RadGrid>    

// Following is RadMenu definition

<telerik:RadContextMenu ID="RadMenu1" runat="server" Skin="Vista"  OnClientItemClicked="OnClientItemClickedHandler">          
        </telerik:RadContextMenu>

function OnClientItemClickedHandler(sender, eventArgs)
   {
        var menu1 = <%=RadMenu1.ClientID %>;
        alert (menu1.Items.length);//null (error)

alert (eventArgs.Item.Text);//null (error)
   }


----------------------------------------code behind to populate items in radmenu--------------------


protected void Page_Load(object sender, EventArgs e)
{
 RadMenuItem menuItem = new RadMenuItem();

 for (int i = 0; i < menuItems.Length; i++)
            {
                menuItem = new RadMenuItem();
                menuItem.Text = menuItems[i];
                menuItem.Value = menuItems[i];

                RadMenu1.Items.Add(menuItem);
               
            }

}

Please help me out.

Thanks,
Jas
0
Jas
Top achievements
Rank 1
answered on 05 Dec 2008, 02:23 PM
Can someone please address to my problem ?

0
Georgi Krustev
Telerik team
answered on 05 Dec 2008, 04:35 PM
Hello Jas,

Thank you for getting back to us.

Unfortunately we couldn't reproduce this javascript error. RadMenu is recreated from the ViewState when its property EnableViewState is set to true.

Second problem is that your are not using the proper methods to get clicked item in RadMenu control. Please review this link for further information. Here is code-snippet of OnClientItemClickedHandler method:
function OnClientItemClickedHandler(sender, eventArgs) 
                { 
                    alert(eventArgs.get_item().get_value()); //returns current selected item in RadMenu 
                } 

Please refer to attached project to this message to find a proper solution of your problems.

Greetings,
Georgi Krustev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Jas
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Jas
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or