Hello,
I am working on adding a GridComboBoxColumn to a SfDataGrid. I am attempting to create a GridComboBoxColumn definition in xaml that has an ItemSource, SelectedValuePath, and DisplayMemberPath binding to property values of its DataContext. Are you able to provide examples on how we can create such bindings in a GridComboBoxColumn?
<syncfusion:SfDataGrid x:Name="dataGrid" ItemsSource="{Binding People}" AutoGenerateColumns="False" DataContext="{StaticResource Model}" > <syncfusion:SfDataGrid.Columns> <syncfusion:GridTextColumn MappingName="Name" HeaderText="Name" ></syncfusion:GridTextColumn> <syncfusion:GridComboBoxColumn MappingName="FruitId" HeaderText="Favorite Fruit" ItemsSource="{Binding FruitsOption}" DisplayMemberPath="Name" SelectedValuePath="Id" /> </syncfusion:SfDataGrid.Columns> </syncfusion:SfDataGrid> |
Hi Sweatha,
My understanding of the example GridComboBoxColumn properties are the following:
MappingName - the integer id property on the grid row that holds the combobox cell's value
ItemSource - the collection of data objects we can choose from on the combobox
DisplayMemberPath - the string property value of the data object we want to display on the combobox
SelectedValuePath - the integer id property value of the data object we want to store as the combobox cell's value
Are you able to confirm that the above definitions are correct?
I am working on a GridComboBoxColumn that has the defined properties MappingName, ItemSource, DisplayMemberPath, and SelectedValuePath. It is able to display the correct property name and update the selected value correctly via DisplayMemberPath and SelectedValuePath from the ItemSource. However, this combo box only displays the values when it is being focused and used. This means that all comboboxes within the GridComboBoxColumn do not display a textblock of the MappingName property value, but the value only appears when you click and edit the ComboBox cell.
How can I make the TextBlock on the ComboBox on each row visible even when you are not selecting a ComboBox to edit?
My GridComboBoxColumn has the same string path value for MappingName and SelectedValuePath by coincidence. Although they have the same string path value, they are two different data context properties - that being the data object in the ItemsSource and the data row object. Would this be a problem in showing the TextBlock value when the ComboBox is not focused?
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Hi Sweatha,
It seems that even if the MappingName is correctly bound and SelectedValuePath is aligned, the value still does not display in viewmode. Here are the example data objects I am working with.
The data object grid row: int displayId, string displayName
The data object in ItemsSource: int displayId, string displayName
Are you able to troubleshoot and provide an example in which we are rendering a GridComboBoxColumn with a MappingName to int displayId from the grid row object, and using int displayId and string displayName for SelectedVauePath and DisplayMemberpath from a data object in ItemsSource?
Best,
Eric