Hey,
I want to export a grid that has combo editor fields. My problem is that, by default, it is exporting the values and not the display members.
Looking at the excel exporter, I saw that it has a CellExporting event where I can set a custom Value on the event args. I'm guessing that this would be the ideal spot for me to somehow grab the text? My problem is that CellValuePresenter.FromRecordAndField returns null here. I want to use CellValuePresenter.Editor.Text as the Value. Am I doing something wrong? In the worst case, I suppose I could use the Cell's value to key into my drop down list and get out the displayed text myself -- is this my best option?
Thanks
I'm still having the same issue even after I upgraded to the latest release.
Hello Neeraj,
The service release containing the fix for your issue is out, you can download it from: https://es.infragistics.com/Membership/Default.aspx?panel=Downloads#Downloads
I'd be glad to receive a feedback on the outcome.
I have created a support case number CAS-69345-9H52M9 for you about this behavior and I have linked it with Development issue 82921 on our internal tracking system.
I will leave this case open and update you with any new information after the review. You can also continue to send updates to this case at any time.
You can view the status of the development issue connected to this case by going to the “My IG” tab on our website, hovering to the "My Support Activity" dropdown and selecting the "Development Issues" tab.
Please let me know if you need more information.
The clone of the grid being exported is not in the visual nor logical tree so the FindAncestor won't work. We can look into this to see if we can change it such that it is at least in the logical tree but for now I would recommend changing the path to use the DataPresenter (see below) and also handle the BeginExport event of the exporter and set the DataContext on the clone grid provided in that event. e.g.
<Style x:Key="stockEditor" TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsSource" Value="{Binding Path=Host.DataPresenter.DataContext.AdditionalDesc, RelativeSource={RelativeSource Self}}" /> <Setter Property="DisplayMemberPath" Value="Value" /> <Setter Property="ValuePath" Value="Id" /> </Style>
private void OnExportClicked(object sender, RoutedEventArgs e) { const string Path = @"c:\withcombo.xlsx"; var grid = this.grid; DataPresenterExcelExporter exporter = new DataPresenterExcelExporter(); exporter.BeginExport += (o, args) => { args.DataPresenter.DataContext = grid.DataContext; }; exporter.Export(grid, Path, WorkbookFormat.Excel2007); Process.Start(Path); }
DataPresenterExcelExporter exporter = new DataPresenterExcelExporter(); exporter.BeginExport += (o, args) => { args.DataPresenter.DataContext = grid.DataContext; }; exporter.Export(grid, Path, WorkbookFormat.Excel2007);
Process.Start(Path); }
Hi Andrew,
The sample provided by you works correctly. But for some reason the below code doesn't work for me
Please look at the code snippet which I use to set the DisplayMemberPath and ValuePath to value and Id properties of AdditionalDesc.
<igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsSource" Value="{Binding Path=DataContext.AdditionalDesc, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" /> <Setter Property="Background" Value="{Binding Path=Value,RelativeSource={RelativeSource Self}, Converter={StaticResource NullValueToRedBrushConverter}}"/> <Setter Property="DisplayMemberPath" Value="Value" /> <Setter Property="ValuePath" Value="Id" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings>
Thanks,
Neeraj