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

RadGrid and GridViewComboBoxColumn Binding problems

6 Answers 184 Views
GridView
This is a migrated thread and some comments may be shown as answers.
zero
Top achievements
Rank 1
zero asked on 09 Dec 2009, 03:07 PM
 Hi,

I am using WPF Telerik controls in a WPFApplication using MVVM pattern.

All controls binding is throw ObservableCollections, for the RadGrid the binding is fine but for the GridViewComboBoxColumn binding it's not.

In fact GridViewComboBoxColumn is binding to another ObservableCollections via
ItemsSource="{Binding MyCollection}"
DataMemberBinding="{Binding Property}"
DisplayMemberPath="Label"
SelectedValueMemberPath="Value"

but it doesn't work.

Can GridViewComboBoxColumn support another collection binding other than RadGrid Collection Binding ??

Thx

6 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 10 Dec 2009, 09:47 AM
Hi zero,

For such scenarios GridViewComboBoxColumn exposes the ItemsSourceBinding property.

In short : ItemsSourceBinding is an alternative to ItemsSource in case you need a separate combobox itemssource for each row as well as you need to bind in XAML rather than set ItemsSource in codebehind.

The syntax would be something like :

ItemsSourceBinding="{Binding {StaticResource MyCollection}}"

or if the 'MyCollection' is a property of the row item ( your business object)

ItemsSourceBinding="{Binding MyCollection}"

* For example if you bind the RadGridView to a collection of Continent objects and each Continent has a Countries collection property  you may use:

ItemsSourceBinding="{Binding Countries}"

And if the Countries collection is not a property of the Continent object , the  you may provide the collection as a static resource and use:

ItemsSourceBinding="{Binding {StaticResource Countries}}"


All the best,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Zeone Informatica
Top achievements
Rank 2
answered on 20 Apr 2012, 02:53 PM
Hello, I Have the followind data model in my DB as example.


My GridView is binding to "VeiclesUsage" having:

 



<telerik:RadGridView AddingNewDataItem="grd_geral_AddingNewDataItem" AutoGenerateColumns="False" CanUserInsertRows="True" Margin="6,285,0,0" Name="grd_geral" ShowGroupPanel="False">

<telerik:RadGridView.Columns>

 

<telerik:GridViewComboBoxColumn DataMemberBinding="{Binding StaffID}" DisplayMemberPath="Name" Header="STaff" IsComboBoxEditable="True" SelectedValueMemberPath="ID" UniqueName="tipo_dist" Width="100" />

 

<telerik:GridViewComboBoxColumn DataMemberBinding="{Binding VehicleID}" DisplayMemberPath="Name" Header="Vehicle" IsComboBoxEditable="True" SelectedValueMemberPath="ID" UniqueName="Res" Width="150*" />

 ...


Is possible to use ItemsSourceBinding to when I chose The STaff from the Combobox he Selectes automatic the vehicles associated to him in the Staff/Vehicles table?


The itemsSource of both combobox are loaded like this:

DirectCast(Me.grd_geral.Columns("tipo_dist"), GridViewComboBoxColumn).ItemsSource = mycontext.CBO_Staff

DirectCast(Me.grd_geral.Columns("Res"), GridViewComboBoxColumn).ItemsSource = mycontext.CBO_Vehicles

Tanks in advance

0
Maya
Telerik team
answered on 20 Apr 2012, 03:26 PM
Hi Miguel,

Please take a look at this blog post for a reference.


All the best,
Maya
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Zeone Informatica
Top achievements
Rank 2
answered on 22 Apr 2012, 11:48 AM
Tanks Maya, I Think is the solution for the problem, but isn't there any example in VB?
0
Zeone Informatica
Top achievements
Rank 2
answered on 03 May 2012, 11:57 AM
Please no one?
0
Maya
Telerik team
answered on 03 May 2012, 12:15 PM
Hello Miguel,

You can try using Telerik VB to C# converter.  

Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
zero
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Zeone Informatica
Top achievements
Rank 2
Maya
Telerik team
Share this question
or