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

Get radgridbutton to string next in the next column

5 Answers 51 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kunal
Top achievements
Rank 1
Kunal asked on 06 Nov 2017, 01:34 PM

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

5 Answers, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 09 Nov 2017, 07:14 AM
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.
0
Kunal
Top achievements
Rank 1
answered on 25 Nov 2017, 04:45 AM

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

 

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

0
Eyup
Telerik team
answered on 29 Nov 2017, 10:57 AM
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.
0
Kunal
Top achievements
Rank 1
answered on 30 Jan 2018, 11:43 AM

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

0
Rumen
Telerik team
answered on 02 Feb 2018, 10:05 AM
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.
Tags
Grid
Asked by
Kunal
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Kunal
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or