export from invisible grid

4 posts, 0 answers
  1. Valentijn
    Valentijn avatar
    21 posts
    Member since:
    Sep 2010

    Posted 18 Feb 2011 Link to this post


    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">











    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 =









    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;






    using (Stream stream = dialog.OpenFile())







    GridViewExportOptions exportOptions = new GridViewExportOptions();



    exportOptions.Format = format;


    exportOptions.ShowColumnFooters =





    exportOptions.ShowColumnHeaders =





    exportOptions.ShowGroupFooters =





    gridExport.Export(stream, exportOptions);
















  2. Vanya Pavlova
    Vanya Pavlova avatar
    2019 posts

    Posted 22 Feb 2011 Link to this post

    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)
       //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!
  3. Michael Gaigg
    Michael Gaigg avatar
    9 posts
    Member since:
    Dec 2009

    Posted 04 Mar 2011 Link to this post

  4. Andrew
    Andrew avatar
    7 posts
    Member since:
    Oct 2011

    Posted 06 Oct 2011 Link to this post

    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.
Back to Top