Csv export missing data in GridTemplateColumn

8 posts, 0 answers
  1. Alexandre BARBIER
    Alexandre BARBIER avatar
    14 posts
    Member since:
    May 2009

    Posted 25 Aug 2010 Link to this post

    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 :
    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
  2. Alexandre BARBIER
    Alexandre BARBIER avatar
    14 posts
    Member since:
    May 2009

    Posted 30 Aug 2010 Link to this post

    Please help ! ... :)
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 30 Aug 2010 Link to this post

    Hello Alexandre,

    First, I recommend that you set ExportOnlyData="false" when exporting GridTemplateColumns to CSV. Second, you can replace the Literal controls with Labels since RadGrid strips the Literals by default.

    I hope this helps.

    Kind regards,
    Daniel
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Alexandre BARBIER
    Alexandre BARBIER avatar
    14 posts
    Member since:
    May 2009

    Posted 30 Aug 2010 Link to this post

    Thanks for answer.
    I've replaced all the literals by labels.
    Set exportOnlyData to false

    unfortunately I got a JS error and no csv file :( :
    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; InfoPath.3; .NET CLR 3.5.30729; .NET CLR 3.0.30729; MS-RTC LM 8; .NET4.0C; .NET4.0E)
    Timestamp: Mon, 30 Aug 2010 15:34:51 UTC


    Message: 'this.ColGroup.Cols' is null or not an object
    Line: 3838
    Char: 1
    Code: 0
    URI: http://serverurl/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_PlaceHolderMain_boconges_radscript_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bTelerik.Web.UI%2c+Version%3d2010.1.519.35%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3afr-FR%3afcd44c12-f50d-4937-b05d-1aa46b5c5b3e%3a24ee1bba%3a1e771326%3a2bef5fcc%3a58366029%3aaa288e2d


    It seems that Export is not supported in ajaxified grid. (http://www.telerik.com/help/aspnet-ajax/grdexportwithajax.html)
    I will try the workaround ....
  6. Alexandre BARBIER
    Alexandre BARBIER avatar
    14 posts
    Member since:
    May 2009

    Posted 30 Aug 2010 Link to this post

    So, I disabled the ajax when exporting to csv.
    I got the csv file

    But the problem is already here :-(
  7. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 02 Sep 2010 Link to this post

    Hello Alexandre,

    Can you please post the modified code in this thread? This way I will be able to find the problem and then provide more to-the-point answer. Alternatively you can attach the files to a regular support ticket.

    Regards,
    Daniel
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Alexandre BARBIER
    Alexandre BARBIER avatar
    14 posts
    Member since:
    May 2009

    Posted 03 Sep 2010 Link to this post

    Hello

    I cannot attach the full project source because too many components are involved to allow the page to run.
    So I've started a new sample project that use the same approach...

    But Actually I can not reproduce the problem. The CSV export work like a charm in my sample ! 

    Only when I set RadGrid1.ExportSettings.ExportOnlyData to true, I can reproduce this issue on my sample project. But in my "real" project I set this property to false but it's change nothing :(

    I will try to find the difference between my real project and the sample project and if I can reproduce the issue, I will post the code to the forum !

    Thanks !
    Regards.
  9. Irving
    Irving avatar
    12 posts
    Member since:
    Jan 2014

    Posted 13 Mar in reply to Daniel Link to this post

    Daniel said:Hello Alexandre,

    First, I recommend that you set ExportOnlyData="false" when exporting GridTemplateColumns to CSV. Second, you can replace the Literal controls with Labels since RadGrid strips the Literals by default.

    I hope this helps.

    Kind regards,
    Daniel
    the Telerik team
     
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
     

     

    This totally helps me with the problem i'm facing thanks !!

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017