This is a migrated thread and some comments may be shown as answers.
telrik radgrid on row image button click
8 Answers 63 Views
This is a migrated thread and some comments may be shown as answers.
Ravi
Top achievements
Rank 1
Ravi asked on 27 May 2014, 07:17 AM
I have radgrid  control   i want to click on print image button    to  execute some code  
which event should i used?

8 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 27 May 2014, 10:18 AM
Hi Ravi,

I guess you are using ASP ImageButton inside the RadGrid. You can use OnClick and OnClientClick event of ImageButton Based on your scenario. Please elaborate your requirement if it doesn't help.

Thanks,
Princy.
0
Ravi
Top achievements
Rank 1
answered on 27 May 2014, 12:37 PM
Hi princy's  
I  have telerik  RadGrid,     dynamically    data coming through database    my requirement is   i want to open popup window     when i click on Print image Button  each row have  Pdf file     Please see attchment You will get some idea   
 here is my aspx code 
   <telerik:RadGrid ID="dgrdInbox" runat="server" AutoGenerateColumns="false" GridLines="None"
                        EnableAJAX="true" AllowSorting="true" Skin="Default" SkinsPath="../Assets/RadControls/Grid/Skins/"
                        RadControlsDir="~/Assets/RadControls/" EnableViewState="true" AllowMultiRowSelection="true"
                        Width="100%" AllowPaging="true" PageSize="10" PagerStyle-ShowPagerText="false"
                        Height="350px">
 <ClientSettings Scrolling-AllowScroll="true" AllowColumnsReorder="true" ColumnsReorderMethod="Reorder"
                            ReorderColumnsOnClient="true">
                            <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                            <Selecting AllowRowSelect="true" />
                        </ClientSettings>

   <MasterTableView DataKeyNames="AutoID" HierarchyDefaultExpanded="false"
                            Width="100%">
 <Columns>
                                <telerik:GridTemplateColumn HeaderButtonType="TextButton" HeaderStyle-Width="15px"
                                    Reorderable="false" UniqueName="checkColumn">
                                    <HeaderTemplate>
                                        <asp:CheckBox runat="server" ID="cboxall" EnableViewState="false" OnCheckedChanged="ToggleRowSelection"
                                            AutoPostBack="true" />
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <asp:CheckBox runat="server" ID="cboxRecord" AutoPostBack="true" OnCheckedChanged="ToggleChildRowSelection" />
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
  <telerik:GridButtonColumn CommandName="Print" Text="Print" UniqueName="Printfile"
                                   ButtonType="ImageButton" ImageUrl="../Assets/Images/print1.png" HeaderStyle-Width="10px">
                                   </telerik:GridButtonColumn> 
  <telerik:GridImageColumn ImageUrl="../Assets/Images/audio.gif" HeaderStyle-Width="10px"
                                    ColumnGroupName="img" Reorderable="false" >
                                    <HeaderStyle CssClass="rgHeader LeftBorder" />
                                    <ItemStyle CssClass="LeftBorder" />
                                </telerik:GridImageColumn>

                                <telerik:GridBoundColumn DataField="status" HeaderText="Status" UniqueName="Status"
                                    HeaderStyle-Width="30px" Visible="false">
                                </telerik:GridBoundColumn>
     <telerik:GridBoundColumn DataField="MRN" HeaderText="MRN" UniqueName="MRN" HeaderStyle-Width="30px" Visible="false">
                                </telerik:GridBoundColumn>
    </Columns>
                        </MasterTableView>
                    </telerik:RadGrid


and code behind 

 Private Sub dgrdInbox_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles dgrdInbox.ItemCommand

    If e.CommandName = "Print" Then
  If File.Exists(Server.MapPath("Files\Docs\TempSPrint\") & Resume & ".pdf") Then
                            Dim path As String 
                           
                            path =  "/Files/Docs/TempSPrint/Resume.pdf "
                            Page.ClientScript.RegisterStartupScript(Me.Page.GetType(), "popup", "window.open('" & path & "','_blank', 'Inbox', 'My Window', 'height=600, width=1000,scrollbars=1, addressbar=0');", True)
                        End If
   code is running without any error  but popup window is not opening    which event should i used    ?
 





0
SANJAY
Top achievements
Rank 1
answered on 27 May 2014, 03:30 PM
Hi
Kindly check if you have the script on the .aspx page

<script type="text/javascript">
                function openRw(url) {
                    radopen(url, "MyWindow");
                }       
</script>

Regards
0
SANJAY
Top achievements
Rank 1
answered on 27 May 2014, 03:41 PM
Hi Ravi

Kindly be sure that you have the MyWindow object on aspx page

 <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
                <Windows>
                    <telerik:RadWindow ID="wndPdfPreview" runat ="server" VisibleOnPageLoad="false" VisibleStatusbar="true"
                                       ShowContentDuringLoad= "false" KeepInScreenBounds ="true" VisibleTitlebar="true" ></telerik:RadWindow>
                </Windows>
            </telerik:RadWindowManager>

0
Princy
Top achievements
Rank 1
answered on 28 May 2014, 04:38 AM
Hi Ravi,

The OnItemCommand event will fire on clicking the ImageButton of RadGrid and please do the following modification in your code which works fine at my end.

VB:
Protected Sub dgrdInbox_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs)
    If e.CommandName = "Print" Then
        Dim path As String = Nothing
        path = "introduction.pdf"
        Dim script As String = (Convert.ToString("function f(){showWindow('") & path) + "'); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
        ScriptManager.RegisterStartupScript(Page, Page.[GetType](), "key", script, True)
    End If
End Sub

JavaScript:
<script type="text/javascript">
    function showWindow(path) {
        window.open(path,"_blank");
    }
</script>

Thanks,
Princy.
0
Merv
Top achievements
Rank 1
answered on 10 Oct 2014, 06:06 PM
I am trying to do something similar. I have a radgrid with autogenerated columns.  I add an ImageButton column in code behind that conditionally shows based on another column.  When I click on a visible button, the command event doesn't fire.  Is this only available if the column has been defined in the aspx code?  Do I need to do something different when the column is created in my C# code?

Thanks,
Merv Rutt
0
Eyup
Telerik team
answered on 15 Oct 2014, 09:51 AM
Hello Merv,

Can you please verify that you are following the steps provided in the following article when adding the programmatic columns?
http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Merv
Top achievements
Rank 1
answered on 15 Oct 2014, 11:19 AM
I figured out that I needed to have an OnItemCommand declaration in the aspx code.  After I added that, it worked fine.

Thanks
Asked by
Ravi
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Ravi
Top achievements
Rank 1
SANJAY
Top achievements
Rank 1
Merv
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or