Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
ExcelExporter exports value for Combobox
posted

Hi,

We are using XamGrid v14.0 and using ExcelExporter to export the grid.

One of our fields uses Unbound and has a ComboBox in ControlTemplate, when exporting to Excel the value is always empty. Here is the cell in xamdatagrid:

<dataPresenter:UnboundField x:Name="Code" Label="Code">
                                                    <dataPresenter:UnboundField.Settings>
                                                        <dataPresenter:FieldSettings LabelTextAlignment="Left">
                                                            <dataPresenter:FieldSettings.CellValuePresenterStyle>
                                                                <Style TargetType="{x:Type dataPresenter:CellValuePresenter}">
                                                                    <Setter Property="Template">
                                                                        <Setter.Value>
                                                                            <ControlTemplate>
                                                                                <ComboBox ItemsSource="{Binding DataItem.Parent.Codes}" 
                                                                                          DisplayMemberPath="MyCode" 
                                                                                          SelectedItem="{Binding DataItem.Code, UpdateSourceTrigger=LostFocus}" IsEnabled="{Binding DataItem.Enabled}"/>
                                                                            </ControlTemplate>
                                                                        </Setter.Value>
                                                                    </Setter>
                                                                </Style>
                                                            </dataPresenter:FieldSettings.CellValuePresenterStyle>
                                                        </dataPresenter:FieldSettings>
                                                    </dataPresenter:UnboundField.Settings>
                                                </dataPresenter:UnboundField>

Parents
  • 34810
    Offline posted

    Hello Tam,

    I have been investigating into the behavior you are seeing, and I believe the issue that you are seeing is likely stemming from the underlying cell values of your “Code” UnboundField being null. With the UnboundField, the Cell.Value property needs to be set manually for each record, and the Excel export will be looking at the underlying cell values to find what to export.

    With the above said, it looks like you are binding the SelectedItem of your ComboBox to the Code property on your data item, and so I’m not sure it is necessary for you to be using an UnboundField. It should be possible to change the UnboundField to a Field with a Name of “Code.” This will fill out the underlying Cell values and should allow the Excel export to work correctly.

    Please let me know if you have any other questions or concerns on this matter.

Reply Children
No Data