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

[Solved] SelectedItem in Radgridview Combobox using MVVM

5 Answers 308 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Julio
Top achievements
Rank 1
Julio asked on 01 Aug 2011, 03:45 AM
I use the MVVM design pattern. I absolutely need a TwoWay SelectedItem Dependency property in the GridViewComboBoxColumn. Preferably, without using CodeBehind. How can I accomplish that? Also, I am curious as to why Telerik's chose not provide this most valuable property. Am I missing something?
p.s.: I have already considered and discarded the use of a Control Template with the RadComboBox. I rather use the .NET Grid instead, since I will loose all the fancy features that made me choose Telerik's GridView in the first place.

Thanks in advance for any assistance that you may provide,

Julio

5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 02 Aug 2011, 03:25 PM
Hi Julio,

Indeed GridViewComboBoxColumn does not provide a SelectedItem property as the RadComboBox itself. May you provide a bit more information what is your particular scenario and why do you need such property in this column ?     

 

Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Julio
Top achievements
Rank 1
answered on 02 Aug 2011, 05:23 PM

Hi Maya, maybe this is just a practice that needs to be revisited but when using MVVM pattern I must never code for the control. Therefore, to create a new entry on a GridView or on a editable ComboBox, I just initialize the SelectedItem. Please, bear in mind that Business rules (that force me to initialize the record while taking in consideration the context) and the MVVM design pattern prohibits the use of the features in controls that provides similar functionality. Please, your thoughts…

0
Maya
Telerik team
answered on 02 Aug 2011, 05:30 PM
Hello Julio,

May you provide a bit more information about your scenario and your specific settings and requirements ? Based on the information provided, I am not quite capable of grasping the basic idea.
Generally, following MVVM Patter does not contradict with the fact that the GridViewComboBoxColumn does not have a SelectedItem property. 

 

All the best,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Julio
Top achievements
Rank 1
answered on 04 Aug 2011, 03:13 PM
Hi Maya, all right, I am starting to see your point. I've been trying to come up with an example that can only be done using the SelectedItem but nothing came up so far. What confuses me, though, is that Telerik's other combobox (RadComboBox) provides the SelectedItem property that I was seeking. At best, this is assymetric and does not provide the basic fucntionality of the .NET controls that Telerik claims to deliver for a smooth conversion.

Just to confirm my reasoning: If I need to select a different item in the combobox from my ViewModel all I need is to set the SelectedValue property? If I have a misconception, please provide me with a code sample that navigates the combobox from a VM (no code behing and no coding for control's specific features).

Thanks for your assistance,
0
Maya
Telerik team
answered on 05 Aug 2011, 10:31 AM
Hello Julio,

Basically, the purpose of the RadComboBox (which is the editor of the GridViewComboBoxColumn) is to edit look up values for the underlying data object of the RadGridView, not to get the items of the combo box itself. The idea is to set a property for this item and trough this specific column to bind it to the values in another source. If you want to set a particular property, you can work with the items of the grid and set their properties. As it is in our online documentation, you may set the CountryID property of the Person object.
 

Regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
GridView
Asked by
Julio
Top achievements
Rank 1
Answers by
Maya
Telerik team
Julio
Top achievements
Rank 1
Share this question
or