telrik radgrid on row image button click

9 posts, 0 answers
  1. Ravi
    Ravi avatar
    9 posts
    Member since:
    Apr 2013

    Posted 27 May 2014 Link to this post

    I have radgrid  control   i want to click on print image button    to  execute some code  
    which event should i used?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 May 2014 in reply to Ravi Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ravi
    Ravi avatar
    9 posts
    Member since:
    Apr 2013

    Posted 27 May 2014 in reply to Princy Link to this post

    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    ?
     





  5. SANJAY
    SANJAY avatar
    61 posts
    Member since:
    Jun 2012

    Posted 27 May 2014 in reply to Ravi Link to this post

    Hi
    Kindly check if you have the script on the .aspx page

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

    Regards
  6. SANJAY
    SANJAY avatar
    61 posts
    Member since:
    Jun 2012

    Posted 27 May 2014 in reply to SANJAY Link to this post

    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>

  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 May 2014 in reply to Ravi Link to this post

    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.
  8. Merv
    Merv avatar
    2 posts
    Member since:
    Sep 2014

    Posted 10 Oct 2014 in reply to Princy Link to this post

    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
  9. Eyup
    Admin
    Eyup avatar
    3013 posts

    Posted 15 Oct 2014 Link to this post

    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.

     
  10. Merv
    Merv avatar
    2 posts
    Member since:
    Sep 2014

    Posted 15 Oct 2014 in reply to Eyup Link to this post

    I figured out that I needed to have an OnItemCommand declaration in the aspx code.  After I added that, it worked fine.

    Thanks
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017