XML export bug in RadGridView

9 posts, 0 answers
  1. Charles Covell
    Charles Covell avatar
    11 posts
    Member since:
    Apr 2010

    Posted 09 Feb 2011 Link to this post

    Hi,

    When using the "export to XML" feature of RadGridView, the resulting XML file is not proper XML when the GridView's data contains strings with the "<>" characters with something between them.  This appears to be because XML special characters:
    < > & %
    --are not escaped properly.

    Would it be possible to get a fix/workaround for this?

    Thanks!

    Charley
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 10 Feb 2011 Link to this post

    Hello Charles Covell,

    You can try escaping those characters in the ElementExporting event of RadGridView.

    Kind regards,
    Veselin Vasilev
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. Charles Covell
    Charles Covell avatar
    11 posts
    Member since:
    Apr 2010

    Posted 10 Feb 2011 Link to this post

    Thanks for your response.  I was able to solve the issue by using your workaround.

    In case anyone else reads this topic, here is the code for the ElementExporting callback I used:

    private void myRadGridView_ElementExporting(object sender, GridViewElementExportingEventArgs e)
    {
        if (e.Value != null && e.Value.GetType() == typeof(string))
        {
            e.Value = (e.Value as string).Replace("&", "&");
            e.Value = (e.Value as string).Replace("<", "<");
            e.Value = (e.Value as string).Replace(">", ">");
            e.Value = (e.Value as string).Replace("\"", """);
            e.Value = (e.Value as string).Replace("\'", "&apos;");
        }
    }

    Thanks,

    Charley
  4. ErrolM
    ErrolM avatar
    7 posts
    Member since:
    Sep 2009

    Posted 14 Jul 2011 Link to this post

    Good afternoon Veselin,

    Do Telerik have plans to implement this instead of all developers having to do it themselves?
    I notice there is a ShouldEncodeValue field on the args (though I tried that before searching for this post).

    Cheers,
    Errol
  5. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 20 Jul 2011 Link to this post

    Hi Errol Melvin,

    I am shcheduling this for improvement for our next official release.

    Regards,
    Pavel Pavlov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  6. azbola
    azbola avatar
    13 posts
    Member since:
    Jun 2007

    Posted 09 Jan 2012 Link to this post

    Did this ever make it into a release?

    I seem to now see that headers are correctly encoded, but not data cells?

    Thanks.
  7. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 12 Jan 2012 Link to this post

    Hello Charles,

    Please try the following :
    public MainPage()
    {
        InitializeComponent();
         
        gridView.Exporting += new EventHandler<GridViewExportEventArgs>(gridView_Exporting);
         
    }
     
    void gridView_Exporting(object sender, GridViewExportEventArgs e)
    {
        e.ShouldEncodeValue = true;
    }


    Kind regards,
    Pavel Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  8. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 12 Jan 2012 Link to this post

    Hello Charls ,

    A quick update - for the latest versions please use the ElementExporting event instead .

    * The Exporting event was recently  obsoleted.

    Kind regards,
    Pavel Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  9. Mohd
    Mohd avatar
    19 posts
    Member since:
    Aug 2011

    Posted 16 Jan 2012 Link to this post

    I am waiting for a reply from a long time


    http://www.telerik.com/community/forums/silverlight/gridview/radgrid-export-to-excel-unable-to-maintain-decimal-format-for-number-less-than-4-digits.aspx
Back to Top