GridViewComboBox values not visible when not in focus.

4 posts, 0 answers
  1. Eric
    Eric avatar
    2 posts
    Member since:
    Jun 2011

    Posted 11 Jul 2011 Link to this post

    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.
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 12 Jul 2011 Link to this post

    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!

  3. Eric
    Eric avatar
    2 posts
    Member since:
    Jun 2011

    Posted 12 Jul 2011 Link to this post

    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.
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 15 Jul 2011 Link to this post

    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!

Back to Top