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

export from invisible grid

3 Answers 67 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Valentijn
Top achievements
Rank 1
Valentijn asked on 18 Feb 2011, 12:51 PM
Hi

We are using an invisible grid to make an export to excell.
The problem is that the export is empty.

Here is the xaml and the code we use.
If we debug, we can see that the itemssource does contain 12 items.

Could this be because we fill up the grid right before we export it? Do we need to do anything else?

<

 

 

telerik:RadGridView Visibility="Collapsed" Grid.Row="1" Grid.Column="0" ColumnWidth="*" AutoExpandGroups="True" RowStyleSelector="{StaticResource styleSelector}" AutoGenerateColumns="True" ItemsSource="{Binding}" Margin="0,0,0,0" Name="gridExport" CanUserReorderColumns="False" IsFilteringAllowed="False" IsReadOnly="True" ShowGroupPanel="False">

 

 

 

 

 

</telerik:RadGridView>

 



private

 

 

void menuItemClick(object o, Telerik.Windows.RadRoutedEventArgs e)

 

 

{

 

 

 

 

 

string extension = "xls";

 

 

 

 

ExportFormat format = ExportFormat.Html;

 

 

 

 

 

 

SaveFileDialog dialog = new SaveFileDialog();

 

 

dialog.DefaultExt = extension;

 

dialog.Filter =

 

String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", extension, "Excell");

 

 

dialog.FilterIndex = 1;

 

 

 

if (dialog.ShowDialog() == true)

 

 

{

 

 

 

int? calendarId = null;

 

 

 

 

int? seriesId = null;

 

 

 

 

DateTime date = (DateTime)this.datPlayDate.SelectedValue;

 

 

 

 

foreach (Bass.Web.DataModel.InterteamCalendar cal in this.calendarsDomainDataSource.DataView)

 

 

{

 

 

 

if (date == cal.Date)

 

 

{

 

calendarId = cal.InterteamCalendarId;

 

}

 

}

 

 

 

RadMenuItem item = o as RadMenuItem;

 

 

 

 

if (item.Name != "")

 

 

{

 

seriesId =

 

int.Parse(item.Name);

 

 

}

 

Bass.Web.Services.

 

BASSDomainContext domainContext3 = new Web.Services.BASSDomainContext();

 

 

 

 

EntityQuery<Bass.Web.DataModel.ExportInterteamOnOfficialResults_Result> exportQuery;

 

 

exportQuery = domainContext3.GetExportInterteamOnOfficialResultsQuery(calendarId, seriesId);

 

domainContext3.Load(exportQuery, lo =>

 

{

 

 

 

if (!lo.HasError)

 

 

{

 

gridExport.ItemsSource = domainContext3.ExportInterteamOnOfficialResults_Results;

 

gridExport.Rebind();

 

 

 

using (Stream stream = dialog.OpenFile())

 

 

{

 

 

 

GridViewExportOptions exportOptions = new GridViewExportOptions();

 

 

exportOptions.Format = format;

 

exportOptions.ShowColumnFooters =

 

true;

 

 

exportOptions.ShowColumnHeaders =

 

true;

 

 

exportOptions.ShowGroupFooters =

 

true;

 

 

gridExport.Export(stream, exportOptions);

 

}

 

 

 

}

 

},

 

false);

 

 

}

 

}


3 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 22 Feb 2011, 01:58 PM
Hi Valentijn,

When the Visibility property of an element is set to Collapsed, it is excluded from the VisualTree. I may suggest you to manually set the Visibility property of RadGridView to Visible just before the exporting and you will get all items:

Copy Code
void menuItemClick(object o, Telerik.Windows.RadRoutedEventArgs e)
{
    this.RadGridView1.Visibility=Visibility.Visible;
   //The rest of your code
}


Please let me know how this works for you.


All the best,
Vanya Pavlova
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Michael Gaigg
Top achievements
Rank 1
answered on 04 Mar 2011, 05:20 PM



0
Andrew
Top achievements
Rank 1
answered on 06 Oct 2011, 06:20 PM
I tried just setting the visibility to visible just before the export, but that didn't do it.

I ended up making the grid hidden instead of collapsed. That works.
Tags
GridView
Asked by
Valentijn
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Michael Gaigg
Top achievements
Rank 1
Andrew
Top achievements
Rank 1
Share this question
or