We have a requirement where we have to bind a gridviewcolumn to a combbox. For this we did the
following steps:
1.Added a style:
<Style x:Key="CustomerTypeStyle"
TargetType="RadGridView:GridViewCell">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadGridView:GridViewCell">
<Border BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}"
Background="{TemplateBinding Background}">
<ComboBox Name="cmbCustomerType"
Height="20"
MinWidth="80"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
ItemsSource="{Binding Path=CustomerTypeList,Mode=OneWay}"
SelectedItem="{Binding Path=Customer,Mode=TwoWay}"
/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="BorderThickness" Value="0,0,1,1"/>
</Style>
2. <RadGrid:GridViewDataColumn x:Name="customertyp" UniqueName="CustomerType" CellStyle="{StaticResource CustomerTypeStyle}"></RadGrid:GridViewDataColumn>
3. The CustomertypeList is actually a list(of customertype) customertype.vb class. This class has an Id and value. The list is populated with the collection objects of customertype. Then the property CustomerTypeList is set to the list(of customertype) object.
Eventhough there is no error occuring, the Grid column having the combobox is not currently showing any data.
Please advice. We are using SL 3.
Thanks in advance.
VR
11 Answers, 1 is accepted
Swap the order of binding ItemsSource and SelectedItem.
no it doesnt work.
Please advice
Thanks in advance
VR
which data are you not able to see , Is it ItemSource or SelectedItem data?
How does type(Class) of object bound to that column look?
If you Have not overridden Tostring, provide DisplayMemberPath for Customer Class.
Kind regards,
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.
In our scenario the gridviewdatacolumn is added in the xaml file. We want the itemssource and the selecteditem to be set.
The Itemsource must be bounded to a list(of customer) class. and the SelectedItem to be an instance of customer class. In addition we have 3 comboboxes in the grid placed. Each combobox is bounded to different class.
1. 1st combobox to Customer
2. 2nd combobox to Order
3. 3rd Combobox to CustomerType
How can we achieve this .We dont want the gridcolumn to be added from the codebehind as the column is already added in the xaml.
Note:
There is a sample where the comboboxEditorSettings is used for this purpose. But in that there is only a single combobox column in the grid. The itemsource for both the combobox column and grid is set to the same collection.
But in our scenario we have 3 comboboxes bounded to 3 different non-related class collections. So how can we achieve this
Thanks in advance
Veena
I am not sure what is causing the problem in your case. However you are always welcome to open a support ticket and attach your project. I will be glad to analyze it and apply any fixes required.
Greetings,
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.
I cant attach the project, as the size is very huge.
I can explain the requirement.
We have a xaml file where we have placed a RadGridView.
The columns are given in xaml file. One of the column for the gridview is a combbox. We are following MVVM pattern.
So a property is written on the ViewModel for the class which get/set the List(of CustomerType) object. This property is binded to the combbox ItemsSource Property. The DisplayMemberPath is set to the "Value" property of the class CustomerType.
We dont want the column to be created/added dynamically.
Can you explain the code/implementation to be done for achieving this.
Thanks in advance
VR
Since working on your project is impossible , lets elaborate on a small sample.
Please find the project attached . It demonstrates the simpliest approach for achieving a scenario similar to yours. I hope that together we can push the sample closer to your requirements.
Regards,
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.
Thanks for the reply and the sample application. But we dont want the Itemsource of the RadGridView or the Combobox column to be set from Code behind. We are having properties for ItemsSource of RadGridView and Combobox Column in the ViewModel. Though the property is getting its value, the UI is not updated accordingly.
We have a property for the collection of customers. The customertype is a property in Customer Class.
The Grid is binded to the List(of customer) class and the customertype for each customer is having multiple values so that (of type List(of idvaluepair) class . We have set the Grid's ItemsSource to the CustomerCollection property in the ViewModel. The combobox column in the xaml is set in this way:
<
telerik:RadGridView x:Name="RadGridView1" AutoGenerateColumns="False" ItemsSource={Binding CustomerCollection}" >
<telerik:GridViewComboBoxColumn DataMemberBinding="{Binding CustomerType, Mode=TwoWay}" DisplayMemberPath="Value" SelectedValueMemberPath="ID" />
The CustomerCollection is a property in ViewModel .
This property contains a property called Customertype which is of type List(of IDValuePair) class.
Please advice on this
Thanks in advance
VR
Can you please paste me here the implementation of your customer class, so I can try modify the example to use your class without the need of setting the ComboBox ItemsSource in code behind.
Can you as well tell me if you are still using the old 812 version of the controls or are you planning to upgrade to the fresh Q3 release.
I find your request very reasonable and we will gladly extend the binding options of GridViewComboBox column for MVVM scenarios as yours.
In case you decide to use the latest Q3 release , we can easily provide the missing feature through our very next Friday internal build.
Greetings,
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.
I'm also facing the same issue. Binding the rad combobox as a column in rad grid view using MVVM. i'm not able to get the selected value of the combo box and how to bind the combobox when i generate the rows at run time?