Excluding GridViewComboBoxColumn

5 posts, 0 answers
  1. Andreas
    Andreas avatar
    23 posts
    Member since:
    Feb 2011

    Posted 21 Feb 2011 Link to this post

    Hi,

    I have a GridViewComboBoxColumn bound to a list of items. What I want to achieve is that you select one item in the GridViewComboBoxColumn and it should be removed from the item list so it cannot be selected again in other rows.
    But the removed item disappears from all rows. So I was wondering if I could use the property EmptyText like in a ComboBox to display the selected value although it is not in the item list anymore. But GridViewComboBoxColumn doesn't seem to provide such a property.
    Could you tell me what would be the best approach to solve this problem?

    Any suggestions would be appreciated.

    Regards, Andreas

  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 21 Feb 2011 Link to this post

    Hi Andreas,

    A working solution might be as follows :

    Use the CellEditTemplate property of the GridViewComboBoxColumn in order to place there a RadComboBox. You will need to handle its loaded event .
    <telerik:GridViewDataColumn DataMemberBinding="{Binding MyProperty}" >
                       <telerik:GridViewDataColumn.CellEditTemplate>
                           <DataTemplate>
                               <telerik:RadComboBox SelectedValue="{Binding MyProperty, Mode=TwoWay}" Loaded="RadComboBox_Loaded" />
                           </DataTemplate>
                       </telerik:GridViewDataColumn.CellEditTemplate>

    Then inside the event handler you can feed it only with the items available for selection.
    ( e.g. ((RadComboBox)Sender).ItemsSource =  ....

    This way in display mode we have the full source and all the items display correctly , and in edit mode , we have only the items available for selection.


    In case you have troubles implementing this , just let me know.

    Regards,
    Pavel Pavlov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. DevCraft banner
  4. Andreas
    Andreas avatar
    23 posts
    Member since:
    Feb 2011

    Posted 22 Feb 2011 Link to this post

    Hi Pavel,

    thanks for the idea with CellEditTemplate. I have tried to do it this way but I don't know how to bind the ComboBox list to the TreeListView. I would like to create all lists in my viewmodel so I skipped the part with the eventhandler from your sample. Using GridViewComboBoxColumn I was able to use the property DataMemberBinding but what is the equivalent in ComboBox? Here is what I have done so far:

                           <telerik:GridViewComboBoxColumn Header="Description"
                                                        DataMemberBinding="{Binding ListId, Mode=TwoWay}"
                                                        ItemsSourceBinding="{Binding List}"
                                                        SelectedValueMemberPath="Id"
                                                        DisplayMemberPath="ManagementPropertyName">
                        
                                <telerik:GridViewComboBoxColumn.CellEditTemplate>
                                    <DataTemplate>
                                        <Controls:RadComboBox ItemsSource="{Binding AvailableList, Mode=TwoWay}"
                                                              SelectedValuePath="{Binding ListId}"
                                                              DisplayMemberPath="ManagementPropertyName"/>
                                    </DataTemplate>
                                </telerik:GridViewComboBoxColumn.CellEditTemplate>

    I can see the list with the available items but the value in the cell doesn't change on new item selection. What am I doing wrong?

    Regards,

    Andreas
  5. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 22 Feb 2011 Link to this post

    Hello Andreas,
    Please try the following:

    <Controls:RadComboBox ItemsSource="{Binding AvailableList}"
                                                              SelectedValue="{Binding ListId, Mode = TwoWay}"
                                                              DisplayMemberPath="ManagementPropertyName"/>

    Regards,
    Pavel Pavlov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  6. Andreas
    Andreas avatar
    23 posts
    Member since:
    Feb 2011

    Posted 22 Feb 2011 Link to this post


    That's it! It's working perfectly.

    Thanks a lot,

    Andreas
Back to Top
DevCraft banner