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

unable to open RAD popup window using RAD GRID and RAD context menu

5 Answers 204 Views
Window
This is a migrated thread and some comments may be shown as answers.
Denny
Top achievements
Rank 1
Denny asked on 24 Jun 2009, 08:10 PM

Dear all,

i am currently using Telerik control for my financial site.

During development of this site i am facing following problem:

  1. in the Rad Grid control i am using Rad Context menu.Now i want to know how can i open a RAD popup window,aginst a click on a particular item of context menu
  2. As well i want to track its ID against which a popup has been opened.

Thanks.
Denny.

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Jun 2009, 06:12 AM
Hi Denny,

You can open RadWindow using the clientside method radopen() after checking the clicked menuitem in OnClientItemClicked event of RadContextMenu. Checkout the following link to know more about different methods that let you to open radwindow from client side.
Opening Windows

You could use the URL Query String to Provide ID as argument to RadWindow. Checkout the link for more information.
Using the URL Query String to Provide Arguments to RadWindow

And here is the code that I tried to achieve the scenario.
ASPX:
 
<telerik:RadGrid ID="RadGrid1" AllowSorting="true" AllowPaging="true" runat="server" AllowMultiRowSelection="True" DataSourceID="SqlDataSource1">  
    <MasterTableView DataSourceID="SqlDataSource1" PageSize="10" TableLayout="Fixed"  
        ClientDataKeyNames="CategoryName" AutoGenerateColumns="True">  
        <Columns>  
        </Columns>  
    </MasterTableView>  
    <ClientSettings>          
        <ClientEvents OnRowContextMenu="OnRowContextMenu" />  
    </ClientSettings>     
</telerik:RadGrid>  
  
<telerik:RadContextMenu ID="RadMenu1" runat="server" OnClientItemClicked="OnClientItemClicked">  
    <Items>  
        <telerik:RadMenuItem Text="Open in new window" Value="open" />  
        <telerik:RadMenuItem Text="Cancel" />  
    </Items>  
</telerik:RadContextMenu>  
  
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">  
</telerik:RadWindowManager> 

JavaScript:
 
<script type="text/javascript">  
function OnClientItemClicked(sender, eventArgs)  
{  
    if (eventArgs.get_item().get_value() == "open")  
    {  
        radopen("ContextMenuWindow.aspx?index="+index+"&value="+value , "window1");  
    }  
}  
var index = 0;  
var value;  
function OnRowContextMenu(sender, eventArgs)  
{  
    var menu = $find("<%=RadMenu1.ClientID %>");  
    var evt = eventArgs.get_domEvent();      
    if(evt.target.tagName == "INPUT" || evt.target.tagName == "A")  
    {  
      return;  
    }  
    index = eventArgs.get_itemIndexHierarchical();      
    var DataItem = $find("<%=RadGrid1.ClientID %>").get_masterTableView().get_dataItems()[index];  
    value = DataItem.getDataKeyValue("CategoryName");  
    menu.show(evt);      
    evt.cancelBubble = true;  
    evt.returnValue = false;  
    if (evt.stopPropagation)  
    {  
       evt.stopPropagation();  
       evt.preventDefault();  
    }  
}  
</script> 

CS code for the page that opened in radwindow (ContextMenuWindow.aspx) for getting passed parameters.
 
protected void Page_Load(object sender, EventArgs e)  
{  
    if (Request["index"] != null && Request["value"] != null)  
    {  
        Response.Write("Clicked row index is " + Request["index"].ToString());  
        Response.Write(" and Clicked row value is " + Request["value"].ToString());  
    }  

Hope this helps,
Shinu.
0
Mario
Top achievements
Rank 2
answered on 09 Apr 2010, 03:53 PM
hi,

why does the code lines in the scriptblock of the asp page:

var DataItem = $find("<%= radGridGroup.ClientID %>").get_masterTableView().get_dataItems()[index];   
 
value = DataItem.getDataKeyValue("Id");  


has to be situated in the function OnRowContextMenu(sender, eventArgs)
and fails to retrieve the value when its situated in the function OnClientItemClicked(sender, eventArgs) 
?

I just get null when its in the OnClientItemClicked function. But works fine in the OnRowContextMenu.

thanks Mario



0
Georgi Tunev
Telerik team
answered on 12 Apr 2010, 08:59 AM
Hi Mario,

To be able to help we need some more information on that issue:
  1. Which (DataItem or value) is null?
  2. Where do you get the value in [index] from?



Regards,
Georgi Tunev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Mario
Top achievements
Rank 2
answered on 12 Apr 2010, 12:09 PM
Hi Georgi,

i based my code on shinus (just above my post). I took the two code lines from the OnRowContextMenu(sender, eventArgs) function and put them into the OnClientItemClicked(sender, eventArgs) function (inside the if clause).

Mario



0
Radoslav
Telerik team
answered on 15 Apr 2010, 11:57 AM
Hello Mario,

The EventArgs object from the OnClientItemClicked function does not have the get_itemIndexHierarchical() function, so if you move the following code snippet:
index = eventArgs.get_itemIndexHierarchical();
var DataItem = $find("<%=RadGrid1.ClientID %>").get_masterTableView().get_dataItems()[index];
value = DataItem.getDataKeyValue("CategoryName");
into the OnClientItemClicked the index variable will be undefined and the code will fail to retrieve the value.

I hope this helps. 

Regards,
Radoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Window
Asked by
Denny
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Mario
Top achievements
Rank 2
Georgi Tunev
Telerik team
Radoslav
Telerik team
Share this question
or