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

exporting and need to modify header text

1 Answer 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Doug
Top achievements
Rank 1
Doug asked on 20 Mar 2017, 02:18 PM
I have added the NeedDataSource sub because of the paging. it is the same as the code below.
once I hit the export sub code (gvMonthly.MasterTableView.ExportToCSV()) at any point afterwards the columns.count = 0
 

exporting using this code
<telerik:RadGrid ID="gvMonthly" AllowPaging="true" CssClass="tblGrid" HeaderStyle-CssClass="thTopHeader"  runat="server" CellSpacing="1" CellPadding="3" DataKeyNames="practiceId" PageSize="50"  />

the vb.net code is
conn.Open()
Dim sql As String = GetLabelRowSQL()
Dim myCommand As SqlCommand = New SqlCommand(sql, conn)
gvMonthly.DataSource = myCommand.ExecuteReader()
gvMonthly.DataBind()
conn.Close()



1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 23 Mar 2017, 08:37 AM
Hi Doug,

Yes, the NeedDataSource is the correct approach. Basically, please make sure that you are not using the DataBind() method to bind the grid. Performing complex grid operations such as Inserting, Deleting, Updating, Hierarchy relations, Grouping, Exporting, Paging, Sorting, Filtering, etc. require accommodating appropriate database operations.  Therefore, we suggest you to avoid Simple Databinding and strongly recommend the use of more advanced databinding methods, which automatically handle the aforementioned functions:

Declarative DataSource (DataSourceID property)
Programmatic Data Binding (NeedDataSource event, + DetailTableDataBind for hierarchy). You should set the DataSource property ONLY within these event handlers.


If you want to style the header, you can set a style directly to the GridHeaderItem cells:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/functionality/exporting/export-formats/word-and-excel-export/html-based-export#styling-rowscells

For example, you can access the header item during PreRender:
http://www.telerik.com/help/aspnet-ajax/grid-using-getitems-getcolumn-methods.html

I hope this will prove helpful.

Regards,
Eyup
Telerik by Progress
Try our brand new, jQuery-free Angular 2 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
Doug
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or