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

6 posts, 0 answers
  1. Denny
    Denny avatar
    10 posts
    Member since:
    Jun 2009

    Posted 24 Jun 2009 Link to this post

    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.

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 25 Jun 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 09 Apr 2010 Link to this post

    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



  5. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 12 Apr 2010 Link to this post

    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.
  6. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 12 Apr 2010 Link to this post

    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



  7. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 15 Apr 2010 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017