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

Excluding GridViewComboBoxColumn

4 Answers 73 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 21 Feb 2011, 11:54 AM
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

4 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 21 Feb 2011, 02:28 PM
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!
0
Andreas
Top achievements
Rank 1
answered on 22 Feb 2011, 12:33 PM
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
0
Pavel Pavlov
Telerik team
answered on 22 Feb 2011, 01:48 PM
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!
0
Andreas
Top achievements
Rank 1
answered on 22 Feb 2011, 02:07 PM

That's it! It's working perfectly.

Thanks a lot,

Andreas
Tags
TreeListView
Asked by
Andreas
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Andreas
Top achievements
Rank 1
Share this question
or