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

How to open rad popup window in radgridview hyperlink ?

13 Answers 242 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Madhu Palakurthi
Top achievements
Rank 1
Madhu Palakurthi asked on 09 Jan 2013, 10:25 AM
Hi,

I have radgrid with template column like this ..

<telerik:GridTemplateColumn UniqueName="Template4" HeaderText="= 7, < 21">
      <ItemTemplate>
        <asp:HyperLink ID="HyperLink2" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "TwentyCount")%>'></asp:HyperLink>                                     
     </ItemTemplate>
</telerik:GridTemplateColumn>

I want to open a rad popup when I am click on hyperlink column.   Rad pop will contain aspx page and grid again. So I want to send parameters also when  I am click on hyperlink column.

If we want open in a new browser directly we can  use this one ..
NavigateUrl='<%#"~/Rpt_Out_DepartmentDaysDue.aspx?UserName= &DaysRange="Seven"&DeptCode=" + DataBinder.Eval(Container.DataItem, "SevenCount").ToString()%>'


But I want to open in a rad popup window. Please help me on this. ..

Thank you in advance ..

13 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 09 Jan 2013, 10:37 AM
Hi,

Try the following code to achieve your scenario.
C#:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        HyperLink link = (HyperLink)item.FindControl("HyperLink1");
        link.Attributes.Add("onclick", "open();return false;");
    }
}
JS:
function open() {
       var window = $find('<%= RadWindow1.ClientID %>');
       window.show();
   }

Thanks,
Shinu
0
Madhu Palakurthi
Top achievements
Rank 1
answered on 10 Jan 2013, 01:08 AM
Hi,

Thanks for quick reply..

But I would like to open aspx page2 in radwindow by sending parameters from aspx page1  ?

0
Shinu
Top achievements
Rank 1
answered on 10 Jan 2013, 04:53 AM
Hi,

Try the following code to achieve your scenario.
aspx:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
            <Windows>
                <telerik:RadWindow ID="RadWindow1" runat="server">
                </telerik:RadWindow>
            </Windows>
</telerik:RadWindowManager>

C#:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
          string value = item.GetDataKeyValue("OrderID").ToString();
        HyperLink link = (HyperLink)item.FindControl("HyperLink1");
        link.Attributes.Add("onclick", "open('" + value+ "');return false;");
    }
}

JS:
function open(value) {
  var oWnd = radopen("BinaryImage.aspx?Id=" + value, "RadWindow1");
    }

Thanks,
Shinu
0
Aaron Whittaker
Top achievements
Rank 1
answered on 11 Jul 2013, 04:40 PM


Hi ,

Radwindow is not opening when I click on hyperlink, the page is  not responding at all. My code is as follows: ItemDataBound is running fine and value is correct but open(value) is not opening radwindow. Please help me.

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RTRBlanketNew.ascx.cs" Inherits="BFNReportProject.Controls.RTRBlanketNew" %>
<div>
 
    <telerik:RadCodeBlock ID="RadCodeBlockBlanket" runat="server">
        <script type="text/javascript">
 
            function RowDblClick(sender, eventArgs) {
 
                sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
 
            }
            function open(value) {
 
                var oWnd = radopen("~/Availability/BFNPages/ItemMaster.aspx?Id=" + value, "RadWindow1");
 
            }
        </script>
 
    </telerik:RadCodeBlock>
 
 
 
    <div class="module" style="height: 20px; width: 350px;">
        <span style="font-weight: bold;">Edit indexes for RTRBlanketNew: </span><span id="BlkOutPut" style="font-weight: bold; color: navy;"></span>
    </div>
    
 
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
 
        <Windows>
 
            <telerik:RadWindow ID="RadWindowDetails" runat="server">
            </telerik:RadWindow>
 
        </Windows>
 
    </telerik:RadWindowManager>
 
    <telerik:RadGrid ID="RadGridBlanketNew" runat="server" Width="95%" ShowStatusBar="true" AutoGenerateColumns="False" OnUpdateCommand="RadGridBlanketNew_UpdateCommand"
        PageSize="20" AllowSorting="True" AllowAutomaticDeletes="false" AllowAutomaticInserts="false" AllowAutomaticUpdates="false" OnItemCreated="RadGridBlanketNew_ItemCreated"
        Skin="Hay" AllowMultiRowEdit="true" OnDetailTableDataBind="RadGridBlanketNew_DetailTableDataBind" OnNeedDataSource="RadGridBlanketNew_NeedDataSource" AllowPaging="true"
        OnItemCommand="RadGridBlanketNew_ItemCommand" OnItemUpdated="RadGridBlanketNew_ItemUpdated" OnItemDeleted="RadGridBlanketNew_ItemDeleted" OnItemInserted="RadGridBlanketNew_ItemInserted"
        OnInsertCommand="RadGridBlanketNew_InsertCommand" OnItemDataBound="RadGridBlanketNew_ItemDataBound" OnDeleteCommand="RadGridBlanketNew_DeleteCommand"
        OnPreRender="RadGridBlanketNew_PreRender" ExpandCollapseColumn-ButtonType="ImageButton" ExpandCollapseColumn-CollapseImageUrl="Images/plus.png"
        ExpandCollapseColumn-ExpandImageUrl="Images/minus.png">
 
 
        <PagerStyle Mode="NumericPages"></PagerStyle>
 
        <MasterTableView Width="100%" DataKeyNames="Vendor_Item_Nr" PageSize="50" Name="Items" HierarchyLoadMode="Client">
            <ParentTableRelation>
 
                <telerik:GridRelationFields DetailKeyField="Store_Nr" MasterKeyField="Vendor_Item_Nr"></telerik:GridRelationFields>
 
            </ParentTableRelation>
 
 
            <DetailTables>
 
                <telerik:GridTableView DataKeyNames="Store_Nr" Name="Stores" Width="100%" runat="server" CommandItemDisplay="Top" HierarchyLoadMode="Client">
                    <NoRecordsTemplate>
                        No Data Found.Total
                    </NoRecordsTemplate>
 
 
                    <Columns>
                        <telerik:GridTemplateColumn UniqueName="Details" HeaderText="Details">
                            <ItemTemplate>
                                <asp:HyperLink  ID="hlDetails" runat="server" Text="Detail" NavigateUrl="~/Availability/BFNPages/ItemMaster.aspx" >
                                </asp:HyperLink>                               
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
 
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                            <HeaderStyle Width="20px"></HeaderStyle>
                            <ItemStyle CssClass="MyImageButton"></ItemStyle>
                        </telerik:GridEditCommandColumn>
 
                        <telerik:GridBoundColumn SortExpression="Store_Nr" HeaderText="Store_Nr" HeaderButtonType="TextButton"
                            DataField="Store_Nr">
                        </telerik:GridBoundColumn>
 
                        <telerik:GridBoundColumn HeaderText="Unit Price" HeaderButtonType="TextButton"
                            DataField="Unit_Price" UniqueName="unitPrice">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="quantity" HeaderButtonType="TextButton"
                            DataField="Quantity" UniqueName="quantity">
                        </telerik:GridBoundColumn>
 
                        <%--<telerik:GridTemplateColumn UniqueName="qty" DataField="quantity" HeaderText="Quantity" SortExpression="qty">
                            <ItemTemplate>
                                <asp:TextBox ID="txtQty" runat="server" Visible="true" Text='<%# Eval("Quantity") %>'>
                                </asp:TextBox>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>--%>
                        <telerik:GridBoundColumn UniqueName="TotalPrice" HeaderText="Total Price" HeaderButtonType="TextButton" DataField="TotalPrice">
                        </telerik:GridBoundColumn>
 
 
                    </Columns>
                    <SortExpressions>
 
                        <telerik:GridSortExpression FieldName="Store_Nr" SortOrder="Ascending"></telerik:GridSortExpression>
 
                    </SortExpressions>
 
                </telerik:GridTableView>
            </DetailTables>
 
            <Columns>
 
 
                <telerik:GridBoundColumn SortExpression="Vendor_Item_Nr" HeaderText="VendorItemNr" HeaderButtonType="TextButton"
                    DataField="Vendor_Item_Nr">
                </telerik:GridBoundColumn>
 
                <telerik:GridBoundColumn SortExpression="unit_price" HeaderText="Unit Price" HeaderButtonType="TextButton"
                    DataField="unit_price">
                </telerik:GridBoundColumn>
 
                <telerik:GridBoundColumn SortExpression="quantity" HeaderText="Quantity" HeaderButtonType="TextButton"
                    DataField="quantity">
                </telerik:GridBoundColumn>
 
                <telerik:GridBoundColumn HeaderText="Total Price" HeaderButtonType="TextButton" DataField="TotalPrice">
                </telerik:GridBoundColumn>
 
 
 
 
 
            </Columns>
 
 
        </MasterTableView>
 
        <ClientSettings>
 
            <Selecting AllowRowSelect="True" EnableDragToSelectRows="True"></Selecting>
 
        </ClientSettings>
    </telerik:RadGrid>
 
 
 
</div>
 
 
 
protected void RadGridBlanketNew_ItemDataBound(object sender, GridItemEventArgs e)
        {
          
          if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Stores")
           {
 
               GridDataItem item = (GridDataItem)e.Item;
 
               string value = item.GetDataKeyValue("Store_Nr").ToString();
 
               HyperLink link = (HyperLink)item.FindControl("hlDetails");
 
               link.Attributes.Add("onclick", "open('" + value + "');return false;");
 
           }
0
Princy
Top achievements
Rank 1
answered on 12 Jul 2013, 09:45 AM
Hi Aaron,

Please try the below code snippet.Please try not using open as function name,then access the HyperLink in ItemCreated event of the radgrid.Hope this helps,Let me know if any concern.

ASPX:
<telerik:RadCodeBlock ID="RadCodeBlockBlanket" runat="server">
 <script type="text/javascript">              
  function dispWindow(value) {                 
    var oWnd = radopen("~/Availability/BFNPages/ItemMaster.aspx?Id=" + value, "RadWindowDetails");                 
   }
 </script>
</telerik:RadCodeBlock>
. . . . . . . . . . . . . . .
 <telerik:GridTemplateColumn UniqueName="Details" HeaderText="Details">
     <ItemTemplate>
        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Availability/BFNPages/ItemMaster.aspx">Details</asp:HyperLink>
      </ItemTemplate>
</telerik:GridTemplateColumn>

C#:
protected void RadGridBlanketNew_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
   {
     if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Stores")
       {
        GridDataItem item = (GridDataItem)e.Item;
        string value = item.GetDataKeyValue("Store_Nr").ToString();
        HyperLink link = (HyperLink)item.FindControl("HyperLink1");           
        link.Attributes.Add("onclick", "dispWindow('" + value + "');return false;");
       }
   }

Thanks,
Princy
0
Aaron Whittaker
Top achievements
Rank 1
answered on 12 Jul 2013, 04:36 PM

 Hi Princy,
Thanks for the reply. I tried your suggestion by added event at ItemCreated but it did not work. This time it is throwing the following javascript error:

Unhandled exception at line 180, column 1 in script block

0x800a1391 - JavaScript runtime error: 'dispWindow' is undefined

Thanks
Asma.


<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RTRBlanketNew.ascx.cs" Inherits="BFNReportProject.Controls.RTRBlanketNew" %>

<div>

<telerik:RadCodeBlock ID="RadCodeBlockBlanket" runat="server">

<script type="text/javascript">

function dispWindow(value) {

var oWnd = radopen("~/Availability/BFNPages/MainOrder.aspx?Id=" + value, "RadWindowDetails");

 

 

}

 

function RowDblClick(sender, eventArgs) {

 

 

sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());

}

 

function open(value) {

var oWnd = radopen("~/Availability/BFNPages/MainOrder.aspx?Id=" + value, "RadWindow1");

 

 

}

 

</script>

</telerik:RadCodeBlock>

0
Aaron Whittaker
Top achievements
Rank 1
answered on 12 Jul 2013, 08:38 PM


Looks like it is not finding the javascript function in radcodeblock.I tried adding  RadAjaxManagerProxy in user control,still its not working.Am I missing anything?
modified code is as follows:
<telerik:RadCodeBlock ID="RadCodeBlockBlanket" runat="server">
        <script type="text/javascript">
            var buttonObj;
 
            var confirmValue = false;
 
            function OnClientClick(btn) {
 
                if (!confirmValue) {
 
                    buttonObj = btn;
 
                    radconfirm('Are you sure?', confirmCallBackFn); return false;
 
                }
 
            }
 
            function confirmCallBackFn(arg) {
 
                if (arg) {
 
                    confirmValue = true;
 
                    buttonObj.click();
 
                }
 
            }
            function dispWindow(value) {               
                var oWnd = radopen("~/Availability/BFNPages/ItemMaster.aspx?Id=" + value, "RadWindowDetails");
            }
 
            function RowDblClick(sender, eventArgs) {
 
                sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
 
            }
            
             
        </script>
 
    </telerik:RadCodeBlock>
   <telerik:RadAjaxManagerProxy ID="RadAjaxProxy1" runat="server">
 
        <AjaxSettings>
 
            <telerik:AjaxSetting AjaxControlID="RadGridStores">
 
                <UpdatedControls>
 
                    <telerik:AjaxUpdatedControl ControlID="RadGridStores" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
 
                    <telerik:AjaxUpdatedControl ControlID="RadWindowManager1" LoadingPanelID="RadAjaxLoadingPanel1">
 
                    </telerik:AjaxUpdatedControl>
 
                 </UpdatedControls>
 
            </telerik:AjaxSetting>        
     
        </AjaxSettings>
 
    </telerik:RadAjaxManagerProxy>
 
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
 
    </telerik:RadAjaxLoadingPanel>
0
Aaron Whittaker
Top achievements
Rank 1
answered on 13 Jul 2013, 11:05 PM
I tried replacing radcodeBlock with 

RadScriptBlock,it did not work..

0
Princy
Top achievements
Rank 1
answered on 15 Jul 2013, 04:00 AM
Hi Aaron,

Here is the full code snippet i tried ,it's working fine at my end.Can u please try this and check if its showing the same error.

ASPX:
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadCodeBlock ID="RadCodeBlockBlanket" runat="server">
    <script type="text/javascript">
        function dispWindow(value) {
            var oWnd = radopen("~/Radgrid5/Default.aspx?Id=" + value, "RadWindowDetails");
        }
    </script>
</telerik:RadCodeBlock>
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
    <Windows>
        <telerik:RadWindow ID="RadWindowDetails" runat="server">
        </telerik:RadWindow>
    </Windows>
</telerik:RadWindowManager>
<telerik:RadGrid ID="RadGridBlanketNew" runat="server" AutoGenerateColumns="False"
    PageSize="10" AllowSorting="True" AllowPaging="true" DataSourceID="SqlDataSource1"
    OnItemCreated="RadGridBlanketNew_ItemCreated">
    <MasterTableView  DataKeyNames="OrderID" Name="Items" HierarchyLoadMode="Client"
        CommandItemDisplay="Top">
        <ParentTableRelation>
            <telerik:GridRelationFields DetailKeyField="OrderID" MasterKeyField="OrderID"></telerik:GridRelationFields>
        </ParentTableRelation>
        <DetailTables>
            <telerik:GridTableView DataKeyNames="OrderID" Name="Stores" Width="100%" runat="server"
                CommandItemDisplay="Top" HierarchyLoadMode="Client" DataSourceID="SqlDataSource2">
                <NoRecordsTemplate>
                    No Data Found.Total
                </NoRecordsTemplate>
                <Columns>
                    <telerik:GridTemplateColumn UniqueName="Details" HeaderText="Details">
                        <ItemTemplate>
                            <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Radgrid5/Default.aspx">Details</asp:HyperLink>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                 . . . . . . . . . . . . . . . .
                </Columns>
                <SortExpressions>
                    <telerik:GridSortExpression FieldName="OrderID" SortOrder="Ascending"></telerik:GridSortExpression>
                </SortExpressions>
            </telerik:GridTableView>
        </DetailTables>
        <Columns>
           . . . . . . . . . . . . . . . .
        </Columns>
    </MasterTableView>
    <ClientSettings>
        <Selecting AllowRowSelect="True" EnableDragToSelectRows="True"></Selecting>
    </ClientSettings>
</telerik:RadGrid>

C#:
protected void RadGridBlanketNew_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
  if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Stores")
    {
     GridDataItem item = (GridDataItem)e.Item;
     string value = item.GetDataKeyValue("OrderID").ToString();
     HyperLink link = (HyperLink)item.FindControl("HyperLink1");
     link.Attributes.Add("onclick", "dispWindow('" + value + "');return false;");
    }
}

Thanks,
Princy

0
Aaron Whittaker
Top achievements
Rank 1
answered on 15 Jul 2013, 03:47 PM

Thank you for trying for me.
I have
telerik:RadScriptManager
in the master page and radgrid and windowmanager are in user control. Can you try it this way and see if it is working as I am still getting same error. I have my usercontrol inside  Radpage View.

<telerik:RadPageView ID="RadPageStore" runat="server">

<uc1:RTRStore runat="server" ID="RTRStore" />

</telerik:RadPageView>


0
Aaron Whittaker
Top achievements
Rank 1
answered on 16 Jul 2013, 03:19 PM
 Any update on this please?
0
Aaron Whittaker
Top achievements
Rank 1
answered on 16 Jul 2013, 10:10 PM

I moved javascript function to page and the radwindow is working but I am still looking a work around for other javascript functions that access the controls inside usercontrol, which  is difficult here, if anybody has good solution, please post it .

Thanks.
0
Maria Ilieva
Telerik team
answered on 18 Jul 2013, 11:08 AM
Hi Aaron,

As you are still experiencing problems in implementing the required functionality on your end it will be best if you could open a regular support ticket and send us sample runnable application which demonstrates  your scenario and the exact problems you are facing. Thus we will be bale to debug it locally and do our best to provide a proper solution for your specific case.

Regards,
Maria Ilieva
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Madhu Palakurthi
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Madhu Palakurthi
Top achievements
Rank 1
Aaron Whittaker
Top achievements
Rank 1
Princy
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or