I'm trying to export my grid content into csv file.
All my grid is created by code into Page_Init method. Here is the code to setup export settings :
my grid contain 11 custom column where content is displayed by a custom item template.
When I use this method : RadGrid1.MasterTableView.ExportToCSV() I got a csv file containing only my first 2 columns wich are not custom column (just GridBoundColumn)
I saw here:http://www.telerik.com/community/forums/aspnet-ajax/grid/csv-exporting.aspx that I need to do special code to get content from my custom template controls and assign it to the item Text property.
Here is my code :
But I've the same issue. The csv file contains the columns but with no values :(
Any idea ?
Thanks
All my grid is created by code into Page_Init method. Here is the code to setup export settings :
RadGrid1.ExportSettings.Csv.ColumnDelimiter = GridCsvDelimiter.Semicolon;
RadGrid1.ExportSettings.Csv.FileExtension =
".csv"
;
RadGrid1.ExportSettings.Csv.RowDelimiter = GridCsvDelimiter.NewLine;
RadGrid1.ExportSettings.FileName =
"export"
;
RadGrid1.ExportSettings.IgnorePaging =
true
;
RadGrid1.ExportSettings.OpenInNewWindow =
true
;
RadGrid1.ExportSettings.ExportOnlyData =
true
;
my grid contain 11 custom column where content is displayed by a custom item template.
When I use this method : RadGrid1.MasterTableView.ExportToCSV() I got a csv file containing only my first 2 columns wich are not custom column (just GridBoundColumn)
I saw here:http://www.telerik.com/community/forums/aspnet-ajax/grid/csv-exporting.aspx that I need to do special code to get content from my custom template controls and assign it to the item Text property.
Here is my code :
void
RadGrid1_ItemCommand(
object
source, GridCommandEventArgs e)
{
if
(e.CommandName == RadGrid.ExportToCsvCommandName)
{
foreach
(GridDataItem item
in
RadGrid1.MasterTableView.Items)
{
var typeCompteurs = from tc
in
DbContext.TypeCompteurs
orderby tc.Ordre
select tc;
foreach
(var t
in
typeCompteurs)
{
Literal lt = item[t.LibelleTypeCompteur].FindControl(
"ctrlAcquis_"
+ t.LibelleTypeCompteur)
as
Literal;
if
(lt !=
null
)
item[t.LibelleTypeCompteur].Text = lt.Text;
}
}
RadGrid1.MasterTableView.ExportToCSV();
}
}
But I've the same issue. The csv file contains the columns but with no values :(
Any idea ?
Thanks