Get radgridbutton to string next in the next column

6 posts, 1 answers
  1. Kunal
    Kunal avatar
    8 posts
    Member since:
    Sep 2017

    Posted 06 Nov 2017 Link to this post

    Hey All, 

     

    So i have a Radgrid with a radgridcolumnbutton;

     

        <telerik:GridButtonColumn ButtonType="ImageButton" 
            FilterControlAltText="Filter PDFExport column" HeaderText="PDF" 
            ImageUrl="Icons\PDF_Export.png" CommandName="generateSamplePDF_click"  UniqueName="generateSamplePDF_click" >
        </telerik:GridButtonColumn>

     

    What need this button to do is to execute the the below which creates a pdf report

     

        Protected Sub generateSamplePDF_click(ByVal sender As Object, ByVal e As ...............................)

            Dim strPath As String = ""
            Dim sampleID As String = ""
            Dim filename As String = ""

            sampleID = *****whatever text is in  column 2 of the row where the button whas selected****

    ' this is what is used before  sampleID = grdTests.Rows(e.CommandArgument).Cells(0).Text

        

            Dim path As String = Server.MapPath("LimsPDF") & "\" & Session("loggedCompanyID") & "\"".pdf"
            strPath = Server.MapPath("~/PDF/pdf_sample_" & sampleID & ".pdf")
            filename = "pdf_sample_" & sampleID & ".pdf"
            Report_Result_UtilityClass.generateSamplePDF(strPath, sampleID)


            Response.ContentType = "application/pdf"
            Response.AddHeader("Content-Disposition", "attachment;filename=" & filename)
            Me.EnableViewState = False
            Response.WriteFile(strPath)
            Response.Flush()
            Response.Close()

        End Sub

     

    any help would be very much appreciated

  2. Answer
    Eyup
    Admin
    Eyup avatar
    3825 posts

    Posted 09 Nov 2017 Link to this post

    Hello Kunal,

    You can use the following approach to achieve this requirement:
    <telerik:GridButtonColumn ... CommandName="generateSamplePDF">
    VB:
    Protected Sub RadGrid1_ItemCommand(sender As Object, e As GridCommandEventArgs)
        If e.CommandName = "generateSamplePDF" Then
            Dim item As GridDataItem = e.Item
            Dim value As String = item("ShipName").Text
        End If
    End Sub

    Alternatively, you can use the GetDataKeyValue method:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-raw-field-data-and-key-values

    I hope this will prove helpful. In addition, you can also check the built-in PDF exporting capability provided by RadGrid:
    http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/exporting/pdf-export/defaultcs.aspx

    Regards,
    Eyup
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Kunal
    Kunal avatar
    8 posts
    Member since:
    Sep 2017

    Posted 24 Nov 2017 in reply to Eyup Link to this post

    Hi Eyup,

    Thank you for responding, really appreciate it!

    I have tried to get round this issue using your example but every time i click on the export image the grid renders but wont output anything.  Have i missed something ? the export class is working as i'm using it on other pages.

    -------------

       <telerik:GridButtonColumn ButtonType="ImageButton" 
            HeaderText="PDF"
            ImageUrl="Icons\PDF_Export.png" UniqueName="generateSamplePDF" CommandName="generateSamplePDF">
        </telerik:GridButtonColumn>

     

    VB:

        Protected Sub generateSamplePDF(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs)

            Dim strPath As String = ""
            Dim sampleID As String = ""

            If e.CommandName = "generateSamplePDF" Then

                Dim item As GridDataItem = e.Item
                sampleID = item("SampleID").Text

            End If

            Dim filename As String = ""

            Dim path As String = Server.MapPath("LimsPDF") & "\" & Session("loggedCompanyID") & "\"".pdf"
            strPath = Server.MapPath("~/PDF/pdf_sample_" & sampleID & ".pdf")
            filename = "pdf_sample_" & sampleID & ".pdf"
            HistoricalReports_UtilityClass.generateSamplePDF(strPath, sampleID)



            Response.ContentType = "application/pdf"
            Response.AddHeader("Content-Disposition", "attachment;filename=" & filename)
            Me.EnableViewState = False
            Response.WriteFile(strPath)
            Response.Flush()
            Response.Close()

        End Sub

     

    -----------------------------

  4. Eyup
    Admin
    Eyup avatar
    3825 posts

    Posted 29 Nov 2017 Link to this post

    Hello Kunal,

    I am afraid custom implementation of exporting is not supported. Nevertheless, you can check whether you have AJAX enabled and disable it:
    https://www.telerik.com/support/kb/aspnet-ajax/ajaxmanager/details/how-to-disable-ajax-temporarily

    Regards,
    Eyup
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Kunal
    Kunal avatar
    8 posts
    Member since:
    Sep 2017

    Posted 30 Jan 2018 in reply to Eyup Link to this post

    Hi Eyup,

     

    i don't think this is an AJAX issue but i did test by disabling it. 

    I don't understand is why the PDF is being generated on the server side local location with out any issues. All the need the button to do is output the same file on client side.

     

    Best Regards

    Kunal

  6. Rumen
    Admin
    Rumen avatar
    14031 posts

    Posted 02 Feb 2018 Link to this post

    Hello Kunal,

    You said that every time you click on the export image the grid renders but won't output anything. Does the whole page get refreshed? Do you get any errors? Does the problem happen if you replace the image button with a standard button?

    Have you also tried to export the Grid using the ClientExportManager client-side tool?

    Best regards,
    Rumen
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top