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

GridViewComboBox values not visible when not in focus.

3 Answers 76 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 11 Jul 2011, 06:54 PM
I found an almost identical issue as mine is this thread: http://www.telerik.com/community/forums/winforms/gridview/gridviewcomboboxcolumn-value-only-visible-on-edit.aspx

but I am using the Silverlight GridView, not the ASP.net MVC version.

My issue is that my GridViewCombo boxes bind to my data just fine within my GridView, however, the columns within the Grid are blank unless I give a cell within that column focus, then all the values for all the cells within that column appear. Other columns in the ViewGrid not using the GridViewComboBox work just fine.

Hopefully someone can answer this quickly, I've been bounced around the forums for two weeks trying to get this resolved.

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 12 Jul 2011, 09:43 AM
Hi Eric,

 A possible reason for the behavior that you describe would be that the ItemsSource if the column is not set appropriately. The DataContext of the cell is not the ViewModel, but the business object related to the row instead. 

It is better to expose the ViewModel as a static resource on the page and then use it by the binding. This is explained in this help article. You may review this online example (the Example.xaml.cs file) to see how the ComboBoxColumn has been bound the right way.

If you still experience problems, may you please share the way that the ComboBox is bound and the ViewModel that it has been bound to?

Kind regards,
Didie
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Eric
Top achievements
Rank 1
answered on 12 Jul 2011, 06:57 PM
Here is the ItemSource for the entire GridView:
ItemsSource="{Binding SelectedMeasure.Measure_x_Person, Mode=TwoWay}"                             

Here is my XAML for the GridViewComboBox:
UniqueName="Person"
Header="Person"
IsComboBoxEditable="False"
DataMemberBinding="{Binding PersonId, Mode=TwoWay}"
ItemsSource="{Binding People}"
SelectedValueMemberPath="PersonId"
DisplayMemberPath="FullName"

Both SelectedMeasure.Measure_x_Person and People are observable collections exposed by the view model. I am having no databinding issues. This is strictly a display problem

This particular grid actually has two gridviewcombo boxes, in the attached files, you can see how if the cell in one column is selected, all that column's values display correctly, but the other column is blank. If I select a cell in the other column, its values are displayed and the first column goes blank.
0
Dimitrina
Telerik team
answered on 15 Jul 2011, 07:08 AM
Hello Eric,

 As I have already suggested you should expose the ViewModel as a static resource on the page and then use it by the binding. Have you missed checking the help article mentioned in my previous post?

<telerik:GridViewComboBoxColumn
Header="Person OK"
IsComboBoxEditable="False"
DataMemberBinding="{Binding PersonId, Mode=TwoWay}"
ItemsSource="{Binding People, Source={StaticResource MyViewModel}}"
SelectedValueMemberPath="PersonId"
DisplayMemberPath="FullName"/>

I have created a sample project following your business objects. Please review it to check whether using a StaticResource of your ViewModel will solve your problem.

Best wishes,
Didie
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
General Discussions
Asked by
Eric
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Eric
Top achievements
Rank 1
Share this question
or