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

RadGrid Pdf export data now showing

2 Answers 83 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mike
Top achievements
Rank 1
mike asked on 19 Jul 2016, 06:57 PM

fisrt I'm using Visual Studio 2013 and Telerik.Web.UI dll version 2016.2.607.40. I have a grid with a grouped column. when I click the export to PDF button there is no data in the pdf just the headers and footer. I have attached my files. also I've set the gridlines = Both and they do not show in the grid. I've looked at it in both IE and Chrome. can someone show me what I've got wrong.

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" RenderMode="Lightweight" GridLines="Both"
ShowFooter="True" CssClass="rgview" ClientSettings-Resizing-AllowColumnResize="true" Width="100%">
<ExportSettings IgnorePaging="true" OpenInNewWindow="true" ExportOnlyData="true">
<Pdf DefaultFontFamily="Arial Unicode MS" PageTopMargin="45mm" BorderStyle="Medium" BorderColor="#666666"></Pdf>
</ExportSettings>
<MasterTableView CommandItemDisplay="Top" ShowGroupFooter="true" GroupsDefaultExpanded="true" GridLines="Both">
<CommandItemSettings ShowExportToPdfButton="true" ShowRefreshButton="false" ShowAddNewRecordButton="false" ShowPrintButton="true" />
<NoRecordsTemplate>There are no records to display</NoRecordsTemplate>
<Columns>
<telerik:GridBoundColumn Aggregate="First" DataField="DistTyp" HeaderText="Distribution type"
ReadOnly="True" SortExpression="DistTyp" UniqueName="DistTyp" FooterText="Dist. Type: ">
<HeaderStyle Width="150px" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="RqstRedistOrdNbr" HeaderText="Order No." UniqueName="RqstRedistOrdNbr">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="RcvdDt" HeaderText="Date Rec." UniqueName="RcvdDt" DataFormatString="{0:d}">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Mtrl" HeaderText="Material" UniqueName="Mtrl">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="MtrlDescr" HeaderText="Material Desc." SortExpression="MtrlDescr" UniqueName="MtrlDescr">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="MtrlDescr" HeaderText="Quantity" SortExpression="MtrlDescr" UniqueName="MtrlDescr">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn Aggregate="Sum" DataField="TotLbs" DataType="System.Decimal"
HeaderText="Total Lbs" SortExpression="TotLbs" UniqueName="TotLbs" FooterText="Total: ">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn Aggregate="Sum" DataField="InvcAmt" DataType="System.Decimal" DataFormatString="{0:c}"
HeaderText="Invc Amt" ReadOnly="True" SortExpression="InvcAmt" UniqueName="InvcAmt" FooterText="Total: ">
</telerik:GridBoundColumn>
</Columns>
<GroupByExpressions>
<telerik:GridGroupByExpression>
<GroupByFields >
<telerik:GridGroupByField FieldName="DistTyp" />
</GroupByFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
</MasterTableView>
</telerik:RadGrid>

CodeBehind

Private Sub RadGrid1_ColumnCreated(sender As Object, e As GridColumnCreatedEventArgs) Handles RadGrid1.ColumnCreated
  If TypeOf e.Column Is GridGroupSplitterColumn Then
    e.Column.Resizable = False
    e.Column.HeaderStyle.Width = Unit.Pixel(1)
  End If
End Sub
 
Private Sub RadGrid1_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
  If (TypeOf (e.Item) Is GridFooterItem) Then
    Dim dataBoundItem As GridFooterItem = e.Item
    dataBoundItem("DistTyp").Text = "Totals"
    dataBoundItem("InvcAmt").ForeColor = Color.Red
    dataBoundItem("InvcAmt").Font.Bold = True
  End If
End Sub
 
Private Sub RadGrid1_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
  Try
    Dim dt As New DataTable
    dt = GetData()
    RadGrid1.DataSource = dt
  Catch ex As Exception
    Dim s As String = ex.Message
  End Try
 
End Sub
Function GetData() As DataTable
  Dim dt As New DataTable
  Dim dr As DataRow
  dt.Columns.Add("DistTyp")
  dt.Columns.Add("Prog")
  dt.Columns.Add("RqstRedistOrdNbr")
  dt.Columns.Add("RcvdDt")
  dt.Columns.Add("Mtrl")
  dt.Columns.Add("MtrlDescr")
  dt.Columns.Add("TotLbs", Type.GetType("System.Decimal"))
  dt.Columns.Add("InvcAmt", Type.GetType("System.Decimal"))
 
  dr = dt.NewRow
  dr("DistTyp") = "BownBoxFee"
  dr("Prog") = "NSLP"
  dr("RqstRedistOrdNbr") = "1000175861"
  dr("RcvdDt") = "2015-08-05"
  dr("Mtrl") = "100350"
  dr("MtrlDescr") = "PEAS GREEN FRZ CTN-30 LB"
  dr("TotLbs") = CDec("100")
  dr("InvcAmt") = CDec("11.0")
  dt.Rows.Add(dr)
  dr = dt.NewRow
  dr("DistTyp") = "BownBoxFee"
  dr("Prog") = "NSLP"
  dr("RqstRedistOrdNbr") = "1000175862"
  dr("RcvdDt") = "2015-10-05"
  dr("Mtrl") = "100350"
  dr("MtrlDescr") = "PEAS GREEN FRZ CTN-30 LB"
  dr("TotLbs") = CDec("200")
  dr("InvcAmt") = CDec("11.0")
  dt.Rows.Add(dr)
 
  dr = dt.NewRow
  dr("DistTyp") = "DirectDiversionFee"
  dr("Prog") = "NSLP"
  dr("RqstRedistOrdNbr") = "1000175911"
  dr("RcvdDt") = "2015-08-05"
  dr("Mtrl") = "100935"
  dr("MtrlDescr") = "SUNFLOWER SEED BUTTER 6-5#'S"
  dr("TotLbs") = CDec("200")
  dr("InvcAmt") = CDec("111.0")
  dt.Rows.Add(dr)
 
  Return dt
End Function

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Kostadin
Telerik team
answered on 22 Jul 2016, 01:47 PM
Hello Mike,

Please make sure you have declare the SelectFields as well in the GroupByExpressino. Please check out the following code snippet.
<GroupByExpressions>
    <telerik:GridGroupByExpression>
        <GroupByFields>
            <telerik:GridGroupByField FieldName="DistTyp" />
        </GroupByFields>
        <SelectFields>
            <telerik:GridGroupByField FieldName="DistTyp" />
        </SelectFields>
    </telerik:GridGroupByExpression>
</GroupByExpressions>

Regards,
Kostadin
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
mike
Top achievements
Rank 1
answered on 22 Jul 2016, 02:50 PM
Thanks that's what I was missing. Works now
Tags
Grid
Asked by
mike
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
mike
Top achievements
Rank 1
Share this question
or