Export with nested class

6 posts, 0 answers
  1. Onno
    Onno avatar
    2 posts
    Member since:
    Feb 2014

    Posted 18 Feb 2014 Link to this post

    Hi,

    I think we are seeing a problem with Exporting when the class in the collection that the RadGridView binds to has a sub class, and one of the properties of that sub class has a converter on it. This is an example (Sub Item B is causing the trouble):
    <telerik:RadGridView x:Name="testRadGridView" ItemsSource="{Binding ItemList}" AutoGenerateColumns="False">
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=MainItemA}" Header="Main Item A " />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=MainItemB}" Header="Main Item B " />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=SubItem.SubItemA}" Header="Sub Item A" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=SubItem.SubItemB, Converter={StaticResource MyTestConverter}}" Header="Sub Item B" />
        </telerik:RadGridView.Columns>
    </telerik:RadGridView>

    And this is the code:
       public class Item
       {
           public string  MainItemA { get; set; }
           public int  MainItemB { get; set; }
           public SubItem SubItem { get; set; }
       }
       public class SubItem
       {
           public string   SubItemA { get; set; }
           public DateTime SubItemB { get; set; }
       }
        public class TestConverter : IValueConverter
       {
           public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
           {
               DateTime dateTimeValue = (DateTime)value;
                return dateTimeValue.ToString("yyyy-MM-dd HH:mm:ss");
           }
            public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
           {
               throw new NotSupportedException();
           }
       }
     
       public class MainWindowViewModel
       {
           public ObservableCollection<Item> ItemList { get; set; }
     
            public MainWindowViewModel()
           {
               ItemList = new ObservableCollection<Item>();
     
               ItemList.Add(new Item { MainItemA = "Main Item A1", MainItemB = 1, SubItem = new SubItem { SubItemA = "Sub Item A1", SubItemB = new DateTime(2014,1,1,13,12,11) } });
               ItemList.Add(new Item { MainItemA = "Main Item A2", MainItemB = 2, SubItem = new SubItem { SubItemA = "Sub Item A2", SubItemB = new DateTime(1999, 4, 3, 2, 1, 0) } });
           }
       }

    In the Export, the converter is not applied, and the output logging of VS contains this:
    System.Windows.Data Error: 40 : BindingExpression path error: 'SubItem' property not found on 'object' ''ExportElement' (HashCode=6)'. BindingExpression:Path=SubItem.SubItemA; DataItem='ExportElement' (HashCode=6); target element is 'ValueSetter' (Name=''); target property is 'Value' (type 'Object')
    System.Windows.Data Error: 40 : BindingExpression path error: 'SubItem' property not found on 'object' ''ExportElement' (HashCode=6)'. BindingExpression:Path=SubItem.SubItemB; DataItem='ExportElement' (HashCode=6); target element is 'ValueSetter' (Name=''); target property is 'Value' (type 'Object')


    Product version 2013.3.1016.40, VS2010 SP1, Windows 7 x64.

    Any ideas?

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 20 Feb 2014 Link to this post

    Hi,

    There was such an issue and it has already been fixed. Please download our latest official version and test how the export is done.

    Let me know about the result.


    Regards,
    Didie
    Telerik
  3. UI for WPF is Visual Studio 2017 Ready
  4. Onno
    Onno avatar
    2 posts
    Member since:
    Feb 2014

    Posted 20 Feb 2014 in reply to Dimitrina Link to this post

    Mmmh, just tried with 2013.3.1316.40, still the same binding errors.
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 24 Feb 2014 Link to this post

    Hi,

    Thank you for performing this additional test.
    I was able to reproduce the issue at my end and I am going to further investigate it.

    Regards,
    Didie
    Telerik
  6. Pawel
    Pawel avatar
    39 posts
    Member since:
    Apr 2014

    Posted 12 Aug 2015 Link to this post

    Is this bug has been fixed? In my project I have exactly same error.
  7. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 12 Aug 2015 Link to this post

    Hi,

    As it turns out the issue is still not resolved. I made it public so that you can track its progress in the Feedback Portal here:
    Gridview export to excel shows binding errors.

    Regards,
    Dimitrina
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready