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

Export with nested class

5 Answers 90 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Onno
Top achievements
Rank 1
Onno asked on 18 Feb 2014, 02:17 PM
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?

5 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 20 Feb 2014, 02:58 PM
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
0
Onno
Top achievements
Rank 1
answered on 20 Feb 2014, 04:15 PM
Mmmh, just tried with 2013.3.1316.40, still the same binding errors.
0
Dimitrina
Telerik team
answered on 24 Feb 2014, 10:17 AM
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
0
Pawel
Top achievements
Rank 1
answered on 12 Aug 2015, 09:26 AM
Is this bug has been fixed? In my project I have exactly same error.
0
Dimitrina
Telerik team
answered on 12 Aug 2015, 10:15 AM
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
Tags
GridView
Asked by
Onno
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Onno
Top achievements
Rank 1
Pawel
Top achievements
Rank 1
Share this question
or