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

GridViewComboBoxColumn not writing through changing data

0 Answers 68 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 16 Dec 2011, 04:41 PM
Hi,

I have a collection of simple objects ('Docks') that have a Name property which is a string. In a RadGridView I have a column defined as follows:

<telerik:GridViewComboBoxColumn Header="Dock"
                DisplayMemberPath="Name"
                SelectedValueMemberPath="Name"
                DataMemberBinding="{Binding DockName}"
                ItemsSource="{Binding Source={StaticResource LocatorKeeper}, Path=Locator.DocksDataViewModel.DocksCollection}" />

This correctly allows me to choose from entered Docks and assign it to a property of the element from the itemssource of the grid.

If I go back to the grid that is bound to the collection with Docks, I can update the name of a Dock. When I go back to the grid with the combobox column, I now correctly see the name updated in the combobox. However, the underlying object still has the old name saved. What I expect would happen is that the value is also written through the binding and stored in the DockName property of the object.

The current behavior is very misleading since the GUI shows the change to be propagated through the application whereas this is not actually the case.  I would like to know if there is a solution or a workaround for this issue.

Update (19-12-2011): after doing some further thinking it occurred to me that it is bad design to have your dependencies enforced by the presentation layer. The best solution is to simply store a reference to the object that contains the Name, so the type of  'DockName' should be changed from string to DockType and the SelectedValueMemberPath should be removed. After that it works as it should.

Of course, it remains the case the the behavior of the RadComboBox is misleading and it would be better to show a blank instead of the changed value.

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Steven
Top achievements
Rank 1
Share this question
or