Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
896 views
Hi, I am able to export radgrid to excel and pdf. But for excel exporting my grouped column is not exported. Could you please let me know how that works.
I am attaching my radgrid code. Also, i just want HA rollout as group header column and not HAtype. how to do that?
<telerik:RadGrid ID="rgCurrentPromo" runat="server"   Skin="Windows7" OnBiffExporting="rgCurrentPromo_BiffExporting" PageSize="30"  AllowPaging="true" AllowSorting="True">
           <%-- <telerik:RadGrid ID="rgCurrentPromo" runat="server" GridLines="None" AllowSorting="true" Skin="Windows7" Width="745px"  OnItemCreated="rgCurrentPromo_ItemCreated" AutoGenerateColumns="False" AllowPaging="true"> --%>
           <ExportSettings IgnorePaging="true" OpenInNewWindow="true">
         <Pdf PageHeight="210mm" PageWidth="330mm" DefaultFontFamily="Arial Unicode MS" PageTopMargin="30mm" 
              BorderStyle="Medium" BorderColor="#666666"
          </Pdf>
                      
      </ExportSettings>
          <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
              <MasterTableView AutoGenerateColumns="False"  CommandItemDisplay="Top" UseAllDataFields="true">
                  <CommandItemSettings ShowExportToExcelButton="true"   ShowExportToPdfButton="true" />
                  <CommandItemTemplate>
                       <asp:Button ID="ExporttoExcel" runat="server" Text="Export To Excel" CommandName="ExporttoExcel"   OnClick="b1_Click"/>
                     <asp:Button ID="ExportoPDF" runat="server" CommandName="ExporttoPDF" Text="Export To PDF" OnClick="b2_Click" />
                     <%--<asp:ImageButton ID="DownloadPDF" runat="server" OnClick="DownloadPDF_Click" ImageUrl="~/Grid/Examples/Functionality/Exporting/Export-Word-CSV/images/file-extension-pdf-icon.png"
      CssClass="pdfButton"></asp:ImageButton>--%>
                  </CommandItemTemplate>
                     <GroupByExpressions>
              <telerik:GridGroupByExpression>
                  <SelectFields>
                      <telerik:GridGroupByField FieldName="HA" FieldAlias="HAType" />
                  </SelectFields>
                  <GroupByFields>
                      <telerik:GridGroupByField FieldName="HA" />
                  </GroupByFields>
              </telerik:GridGroupByExpression>
          </GroupByExpressions>
          <GroupHeaderItemStyle Font-Bold="true" Font-Size="120%" />
              <Columns>
                    <telerik:GridBoundColumn DataField="CUSTOMER_NAME"  FilterControlAltText="Filter CUSTOMER_NAME column" HeaderText="Customer" ReadOnly="True" SortExpression="CUSTOMER_NAME" UniqueName="CUSTOMER_NAME">
                      <ColumnValidationSettings>
                          <ModelErrorMessage Text="" />
                      </ColumnValidationSettings>
                  </telerik:GridBoundColumn>
                  <telerik:GridBoundColumn DataField="PROMO_NO" DataType="System.Int32" FilterControlAltText="Filter PROMO_NO column" HeaderText="PN" ReadOnly="True" SortExpression="PROMO_NO" UniqueName="PROMO_NO">
                      <ColumnValidationSettings>
                          <ModelErrorMessage Text="" />
                      </ColumnValidationSettings>
                  </telerik:GridBoundColumn>
                  <telerik:GridBoundColumn DataField="PROMO_NM" FilterControlAltText="Filter PROMO_NM column" HeaderText="Promo Name" SortExpression="PROMO_NM" UniqueName="PROMO_NM">
                      <ColumnValidationSettings>
                          <ModelErrorMessage Text="" />
                      </ColumnValidationSettings>
                  </telerik:GridBoundColumn>
                  
                  <telerik:GridBoundColumn DataField="PROMO_DATE" DataType="System.DateTime" FilterControlAltText="Filter PROMO_DATE column" HeaderText="Start Dt" SortExpression="PROMO_DATE"  UniqueName="PROMO_DATE"  DataFormatString="{0:dd/MM/yyyy}">
                      <ColumnValidationSettings>
                          <ModelErrorMessage Text="" />
                      </ColumnValidationSettings>
                  </telerik:GridBoundColumn
                 <telerik:GridBoundColumn DataField="HA" FilterControlAltText="Filter HA column" HeaderText="HA" SortExpression="HA" UniqueName="HA">
                      <ColumnValidationSettings>
                          <ModelErrorMessage Text="" />
                      </ColumnValidationSettings>
                  </telerik:GridBoundColumn>
                  <telerik:GridBoundColumn DataField="PROMO_DESC" FilterControlAltText="Filter PROMO_DESC column" HeaderText="Description" SortExpression="PROMO_DESC" UniqueName="PROMO_DESC">
                      <ColumnValidationSettings>
                          <ModelErrorMessage Text="" />
                      </ColumnValidationSettings>
                  </telerik:GridBoundColumn>
                  <telerik:GridBoundColumn DataField="PROMO_END_DT" DataType="System.DateTime" FilterControlAltText="Filter PROMO_END_DT column" HeaderText="End Dt" SortExpression="PROMO_END_DT" UniqueName="PROMO_END_DT" DataFormatString="{0:dd/MM/yyyy}">
                      <ColumnValidationSettings>
                          <ModelErrorMessage Text="" />
                      </ColumnValidationSettings>
                  </telerik:GridBoundColumn>
                </Columns>
          </MasterTableView>
          <ClientSettings AllowDragToGroup="true" />
  <GroupingSettings ShowUnGroupButton="true" />
      </telerik:RadGrid>
Protected Sub rgCurrentPromo_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles rgCurrentPromo.NeedDataSource
     Using dbContext As New AthenaModel.EntitiesModel()
         Dim firstDate As Date = New DateTime(Now.Year, Now.Month, 1)
         'Select
         'Case when AUTH_CODE is  null Then 'Non-HA Rollout' Else 'HA Rollout' End  AS HA,CUSTOMER.CUSTOMER_NAME, PLUTO.TBLPROMOTIONCODE.PROMO_NO, PLUTO.TBLPROMOTIONCODE.PROMO_NM, PLUTO.TBLPROMOTIONCODE.PROMO_DATE, PLUTO.TBLPROMOTIONCODE.PROMO_END_DT, PLUTO.TBLPROMOTIONCODE.PROMO_DESC
         'FROM PLUTO.TBLPROMOTIONCODE INNER JOIN CUSTOMER ON PLUTO.TBLPROMOTIONCODE.CUSTOMER_ID = CUSTOMER.CUSTOMER_ID
         'WHERE PLUTO.TBLPROMOTIONCODE.PROMO_END_DT>=TRUNC (SYSDATE, 'month') Or PLUTO.TBLPROMOTIONCODE.PROMO_END_DT Is Null;
         Dim query = (From p In dbContext.TBLPROMOTIONCODEs
                 Join c In dbContext.CUSTOMERs On p.CUSTOMER_ID Equals c.CUSTOMER_ID
                 Where p.PROMO_END_DT >= firstDate Or p.PROMO_END_DT Is Nothing
                 Select c.CUSTOMER_NAME, p.PROMO_NO, p.PROMO_NM, p.PROMO_END_DT, p.PROMO_DATE, p.PROMO_DESC, HA = If(p.AUTH_CODE Is Nothing, "Non-HA Rollout", "HA Rollout")).ToList()
         ' Select c.CUSTOMER_NAME, p.PROMO_NO, p.PROMO_NM, promo_enddt = String.Format("{0:MM/dd/yyyy}", p.PROMO_END_DT), promo_dt = String.Format("{0:MM/dd/yyyy}", p.PROMO_DATE), p.PROMO_DESC, HA = IIf(p.AUTH_CODE Is Nothing, "Non-HA Rollout", "HA Rollout")).ToList()
         rgCurrentPromo.DataSource = query
         'rgCurrentPromo.DataBind()
     End Using
 End Sub
 Private isPdfExport As Boolean = False
 Protected Sub rgCurrentPromo_ItemCreated(sender As Object, e As GridItemEventArgs)
     If isPdfExport Then
         FormatGridItem(e.Item)
     End If
     'If TypeOf e.Item Is GridHeaderItem Then
     '    Dim row As RowElement = New RowElement()
     '    Dim cell As CellElement = New CellElement()
     '    cell.MergeAcross = e.Row.Cells.Count - 1
     '    cell.Data.DataItem = "VETS-100A Detail Report from " & AsofReportFromDate & " To " & AsofReportToDate & "  Reporting Time : " & Date.Now.ToString("MM-dd-yyyy H:mm:ss")
     '    cell.StyleValue = "headStyle"
     '    row.Cells.Add(cell)
     '    e.Worksheet.Table.Rows.Insert(0, row)
     '    e.Worksheet.AutoFilter.Range = e.Worksheet.AutoFilter.Range.Replace("R1", "R2")
     'End If
 End Sub
 Protected Sub FormatGridItem(item As GridItem)
     item.Style("color") = "#eeeeee"
     If TypeOf item Is GridDataItem Then
         item.Style("vertical-align") = "middle"
         item.Style("text-align") = "center"
     End If
     Select Case item.ItemType
         'Mimic RadGrid appearance for the exported PDF file 
         Case GridItemType.Item
             item.Style("background-color") = "#4F4F4F"
             Exit Select
         Case GridItemType.AlternatingItem
             item.Style("background-color") = "#494949"
             Exit Select
         Case GridItemType.Header
             item.Style("background-color") = "#2B2B2B"
             Exit Select
         Case GridItemType.CommandItem
             item.Style("background-color") = "#000000"
             Exit Select
     End Select
     If TypeOf item Is GridCommandItem Then
         'needed to span the image over the CommandItem cells 
         item.PrepareItemStyle()
     End If
 End Sub
 'Protected Sub rgCurrentPromo_ItemCommand(ByVal sender As Object, ByVal e As GridCommandEventArgs) Handles rgCurrentPromo.ItemCommand
 '    If e.CommandName = RadGrid.ExportToPdfCommandName Then
 '        isPdfExport = True
 '        rgCurrentPromo.MasterTableView.GetColumn("CUSTOMER_NAME").HeaderStyle.Width = Unit.Pixel(120)
 '        rgCurrentPromo.MasterTableView.GetColumn("PROMO_NO").HeaderStyle.Width = Unit.Pixel(100)
 '        rgCurrentPromo.MasterTableView.GetColumn("PROMO_NM").HeaderStyle.Width = Unit.Pixel(100)
 '        rgCurrentPromo.MasterTableView.GetColumn("PROMO_END_DT").HeaderStyle.Width = Unit.Pixel(100)
 '        rgCurrentPromo.MasterTableView.GetColumn("PROMO_DATE").HeaderStyle.Width = Unit.Pixel(100)
 '        rgCurrentPromo.MasterTableView.GetColumn("PROMO_DESC").HeaderStyle.Width = Unit.Pixel(100)
 '        rgCurrentPromo.MasterTableView.GetColumn("HA").HeaderStyle.Width = Unit.Pixel(120)
 '    End If
 'End Sub
 Protected Sub DownloadPDF_Click(sender As Object, e As EventArgs)
     isPdfExport = True
     rgCurrentPromo.MasterTableView.ExportToPdf()
 End Sub
 Protected Sub rgCurrentPromo_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs)
     If e.CommandName = RadGrid.ExportToExcelCommandName Then
         rgCurrentPromo.ExportSettings.HideStructureColumns = False
         rgCurrentPromo.Rebind()
     End If
 End Sub
 Private isExporting As Boolean = False
 Protected Sub b1_Click(ByVal sender As Object, ByVal e As EventArgs)
     isExporting = True
     rgCurrentPromo.ExportSettings.Excel.Format = GridExcelExportFormat.Biff
     rgCurrentPromo.ExportSettings.IgnorePaging = True
     rgCurrentPromo.ExportSettings.ExportOnlyData = False
     rgCurrentPromo.MasterTableView.AllowPaging = False
     ' rgCurrentPromo.ExportSettings.
     rgCurrentPromo.ExportSettings.FileName = "Current_Promotions"
     rgCurrentPromo.ExportSettings.OpenInNewWindow = True
     rgCurrentPromo.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None
     rgCurrentPromo.MasterTableView.HierarchyDefaultExpanded = True
     rgCurrentPromo.ExportSettings.HideStructureColumns = "false"
     ' rgCurrentPromo.MasterTableView.GroupHeaderTemplate.
  
     'Response.Clear()
     'Response.Buffer = True
     'Response.ContentType = "application/vnd.ms-excel"
     'Response.Charset = ""
     'Me.EnableViewState = False
     'Dim oStringWriter As New System.IO.StringWriter()
     'Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)
     'rgCurrentPromo.RenderControl(oHtmlTextWriter)
     'Response.Write(oStringWriter.ToString())
     'Response.End()
     rgCurrentPromo.Rebind()
     rgCurrentPromo.MasterTableView.ExportToExcel()
 End Sub
 Protected Sub b2_Click(ByVal sender As Object, ByVal e As EventArgs)
     isExporting = True
     rgCurrentPromo.ExportSettings.ExportOnlyData = False
     rgCurrentPromo.ExportSettings.FileName = "Current_Promotions"
     rgCurrentPromo.ExportSettings.OpenInNewWindow = True
     rgCurrentPromo.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None
     rgCurrentPromo.MasterTableView.HierarchyDefaultExpanded = True
     rgCurrentPromo.ExportSettings.Pdf.PageHeader.LeftCell.Text = headerLeftCell
     rgCurrentPromo.ExportSettings.Pdf.PageHeader.LeftCell.TextAlign = GridPdfPageHeaderFooterCell.CellTextAlign.Center
     rgCurrentPromo.MasterTableView.GroupHeaderItemStyle.BackColor = Drawing.Color.Red
     rgCurrentPromo.MasterTableView.ExportToPdf()
 End Sub
 Protected Sub rgCurrentPromo_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles rgCurrentPromo.ItemDataBound
     If isExporting Then
         If e.Item.ItemType = GridItemType.Header Then
             e.Item.BackColor = System.Drawing.Color.White
             e.Item.ForeColor = System.Drawing.Color.Blue
             ' e.Item.Font.Bold = True
             e.Item.Height = Unit.Point(20)
             e.Item.Font.Size = 11
             e.Item.HorizontalAlign = HorizontalAlign.Left
         End If
         If e.Item.ItemType = GridItemType.Item Then
             e.Item.HorizontalAlign = HorizontalAlign.Left
         End If
         If e.Item.ItemType = GridItemType.AlternatingItem Then
             e.Item.HorizontalAlign = HorizontalAlign.Left
         End If
         If e.Item.ItemType = GridItemType.GroupHeader Then
             e.Item.ForeColor = System.Drawing.Color.Red
         End If
     End If
 End Sub
 Protected Sub rgCurrentPromo_BiffExporting(ByVal sender As Object, ByVal e As GridBiffExportingEventArgs)
Daniel
Telerik team
 answered on 10 Apr 2015
1 answer
45 views

Hi,

 

When i in multirowselect true environment i cant highlight cell value and copy

I want both multirowselect and single cell selection facility. How can i keep both facility3

 

lakmal

 

 

 

Pavlina
Telerik team
 answered on 10 Apr 2015
3 answers
78 views

Hi!

I need to make context menu for whole tree. I have context menues for nodes. I need to have context menu in case of user clicking on tree and not on some node. How to make it?

Ivan Danchev
Telerik team
 answered on 10 Apr 2015
1 answer
103 views

I have a screen with several fields, the async upload control and a submit button.

I don't want the upload to take place until the submit button is clicked, as I cannot get the values of the fields on the screen until this time. These fields need to be stored on the same record as the image. The 'handler' is called when you 'select' the file and at this time I am storing a record in the database with the image.

I am able to store the image, get the key from the database, and then do an update to the data once 'submit' is pressed, but I would like to do just one insert command.

If the user decides to exit out of the screen, I have a record stored that is not complete with the rest of the screens information.

Thanks.

Hristo Valyavicharski
Telerik team
 answered on 10 Apr 2015
1 answer
477 views

Hi,

I'm a new to using telerik i want to associate my column to one header text 

in the first pic i have 2 colomn ID STATION adn TIME TAG

i want have                            

                              STATION XXX

              ID STATION              TIME TAG

and in the seconde pic i have create 2 column programmatically 

plz help me

Regards,

Essoufi

Konstantin Dikov
Telerik team
 answered on 10 Apr 2015
1 answer
66 views

Hi,

I am trying to apply my own custom CSS on one of our SharePoint page but I can't seem to make it work. It's for the ContentArea editor when editing a text area. Based on my research, I've read that I have to declare the CSS in the ConfigFile.xml. Also, I've put the actual CSS file under this path:

​

C:\Program Files\Common Files\microsoft shared\Web Server Extensions\wpresources\RadEditorSharePoint\7.2.1.0__1f131a624888eeed\Resources

 

The ConfigFile.xml looks something like this:

<configuration>
<!--<property name="ContentAreaMode">Div</property>-->
<property name="ContentAreaCssFile">
<item>CssEditorCustom.css</item>
</property>
<property name="ToolbarMode">ShowOnFocus</property>
<property name="ToolsWidth">640px</property>  
<property name="ImagesPaths">
<item>/SiteCollectionDocuments</item>
<item>/SiteCollectionImages</item>
</property>
<property name="MaxImageSize">10485760</property>
</configuration>

 

After doing the above, the CSS seems to be not working (i.e. font size, margin, padding, etc.) I haven't noticed any difference.

Am I missing something? Can you please point me to the right direction?

 

Hoping to hear from you soon.

Cheers,
Arnelio

 

 

Marin Bratanov
Telerik team
 answered on 10 Apr 2015
1 answer
104 views

Hi

My Grid is in Batch mode and Has Template column.

 How we can save all changes from external button from server side?

 Thanks

 

 

Pavlina
Telerik team
 answered on 10 Apr 2015
1 answer
85 views

Hello,

 I'm trying to determine if RadMap (ASP.NET and/or Silverlight) can load custom topo into a layer from an internal map server. I was hoping to use GeoServer which supports TMS via an embedded GeoWebCache.

 

Can RadMap ( ASP.NET and/or Silverlight) user multiple layers? I will have a small number of topos to display, and would like to see Bing/Google satellite maps where my own data is not present. Normally I would think that having my own layer over the top of a Bing/Google layer would do this.

 

Could you advise me on how to accomplish my goal please?

 Thanks,

Scott

Misho
Telerik team
 answered on 10 Apr 2015
1 answer
133 views

I have a drop down list inside the radgrid and the button outside the radgrid. Also I have asp.net update panel for making the cursor busy while processing. when I changed the drop down value in less than 2 drop down everything works fine and it update the gradgrid after processing complete.  But when I change the 3 or more dropdown list value, I am getting error message like

 

 Unhandled exception at line 15, column 16485 in http://localhost:85124/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_TSM&compress=1&_TSM_CombinedScriptsJavaScript runtime error: ....

Sys.WebForms.PageRequestManagerTimeoutException: The server request timed out.   etc   kind of error message. â€‹

 

Can you please provide suggestion how can I fixed this issue?

 

Thanks in advance

Eyup
Telerik team
 answered on 10 Apr 2015
1 answer
136 views

Hello,

I was running into problems with too much text being displayed in certain columns within my grid. In ItemDataBound() I used the text.substring method (C#) to shorten the data to appropriate length. This was done similar to the directions provided in this post:

 http://www.telerik.com/forums/limit-amount-of-text-shown-in-data-column

Meanwhile I have implemented the Grid Excel export functionality. Unfortunately, my data within the Excel export is incomplete because it is being shortened to fit my columns. 

 

How can I limit the amount of text shown in a column, but still export all data when using the Excel export functionality?

 

Thanks,
Matt

 

Eyup
Telerik team
 answered on 10 Apr 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?