ComboBox column doesnt show values until you click on it?

9 posts, 0 answers
  1. madladuk
    madladuk avatar
    126 posts
    Member since:
    Dec 2009

    Posted 16 Aug 2010 Link to this post

    Hi,

    When I use the combobox column on the grid view the text values do not show until you click in the grid or the combobox. Could you give me some pointers.

    P
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 16 Aug 2010 Link to this post

    Hello madladuk,

    CAUSE

    Probably you use ElementName binding for that column, e.g.

    <telerik:GridViewComboBoxColumn Header="Category"
           DataMemberBinding="{Binding CategoryID}"
           ItemsSource="{Binding Path=DataContext.Categories, ElementName=RootElement}"
           DisplayMemberPath="CategoryName"
           SelectedValueMemberPath="CategoryID" />  


    This will not work, as the DataContext of the cell would not be the ViewModel, but the business object related to the row instead. We do not recommend such approach.



    SOLUTION

    There are two ways of solving the issue :

    1. Expose the ViewModel as a static resource on the page so that it can be easily accessible by the binding:

    <UserControl.Resources>
       <local:MainPageViewModel x:Key="mainPageViewModel" />
    </UserControl.Resources>
    ...
    <telerik:GridViewComboBoxColumn Header="Category"
               DataMemberBinding="{Binding CategoryID}"
               ItemsSource="{Binding Path=Categories, Source={StaticResource mainPageViewModel}}"
               DisplayMemberPath="CategoryName"
               SelectedValueMemberPath="CategoryID" />

     OR

    2. Set the ItemsSource of the combo column in code behind instead of binding it in XAML:

    private void gridView_DataLoaded(object sender, EventArgs e)
    {
        (gridView.Columns["Category"] as GridViewComboBoxColumn).ItemsSource = GetCategories();
    }

    Hope this helps.

    Greetings,
    Veselin Vasilev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. madladuk
    madladuk avatar
    126 posts
    Member since:
    Dec 2009

    Posted 16 Aug 2010 Link to this post

    Hi, sorry I dont quite understand. On my page I have the domain data source setup which gets an entity called "data_PERSON" this has sub records called "data_DEPENDANT". On the page I have two user controls, the first shows the radgrid with the list of the "data_DEPENDANTs" so the ItemSource of the grid is {Binding Path=data_DEPENDANT} and the combobox is wired up to the domaindatasource in the user control to show the relationship type "picklist_RELATIONSHIP";

    <telerik:GridViewComboBoxColumn
                       Header="Relationship Type"
                       SelectedValueMemberPath="rowguid"
                       DisplayMemberPath="picktext"
                       DataMemberBinding="{Binding Path=relationship, Mode=TwoWay}"
                       ItemsSource="{Binding Data, ElementName=dds}"
                       />

    So I find that the values in the comobox only show when you click the combobox.

    Second problem I have is in the second user control on the page I need this to show the "data_DEPENDANT" for the record selected in the radgrid, i tried setting the DataContext in the second user control to {Binding Path=data_DEPENDANT.CurrentItem} and the masked textbox to Value={Binding Path=Name} but this does not return any information when a record is selected.

    Could you assist?

    Thanks P
  5. madladuk
    madladuk avatar
    126 posts
    Member since:
    Dec 2009

    Posted 16 Aug 2010 Link to this post

    The element "dds" is coming from the page hosting the usercontrol
  6. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 16 Aug 2010 Link to this post

    Hello madladuk,

    Please try setting the ItemsSource of the combobox column in the code behind. That should fix the first problem.

    As for the second one - please set the IsSynchronizedWithCurrentItem property of RadGridView to True.

    Greetings,
    Veselin Vasilev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. madladuk
    madladuk avatar
    126 posts
    Member since:
    Dec 2009

    Posted 16 Aug 2010 Link to this post

    Thanks, i set the IsSynchronizedWithCurrentItem on the grid, however I dont see any data in the second user control;

    <Grid Margin="10,10,30,10" DataContext="{Binding Path=data_DEPENDANT.CurrentItem}">
                    <StackPanel Orientation="Vertical">
                        <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Top" Orientation="Horizontal" Margin="0,1,0,0">
                            <TextBlock Text="Name" Width="120"  VerticalAlignment="Center" />
                    <telerikInput:RadMaskedTextBox  MaskType="None" 
                                                   Width="220" Grid.Column="1"
                                                    telerik:StyleManager.Theme="Windows7"
                                                    Value="{Binding Path=name}"/>
                </StackPanel>

    Thanks P{
  8. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 16 Aug 2010 Link to this post

    Hi madladuk,

    I suggest that you open a new support ticket and attach a sample project demonstrating the issue there. That will help us identify where the problem is and find a solution easier.

    Thanks

    Kind regards,
    Veselin Vasilev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. madladuk
    madladuk avatar
    126 posts
    Member since:
    Dec 2009

    Posted 18 Aug 2010 Link to this post

    Where is GetCategories() coming from? I have a rai datasource within the page named "dds" however if I set the itemsource to dds.data or dds.dataview the page gets an error?

    Thanks
    P
  10. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 18 Aug 2010 Link to this post

    Hi madladuk,

    It is just a name of a sample method which returns the data that should be shown in the combobox.
    It could be any method that returns IEnumerable.

    Sincerely yours,
    Veselin Vasilev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
DevCraft banner