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

gridviewcomboboxcolumn binding to VM

3 Answers 70 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Neogeo
Top achievements
Rank 1
Neogeo asked on 04 Jul 2012, 04:38 PM
I have a Grid with datacontext set to the VM working fine. The VM has a List<Item> and a many to many object Graph List<myReport> of Report/VisitItems.Item

In the detail grid view, the item field is set as gridviewcomboboxcolumn

 <telerik:RadGridView ShowGroupPanel="False" AutoGenerateColumns="False"    ItemsSource="{Binding Path=myReport.visititem}" CanUserInsertRows="True">
<
telerik:GridViewComboBoxColumn x:Name="cbItem" Header="Item Name" UniqueName="ItemName"               
                                EditTriggers="CellClick"
                                ItemsSource="{Binding ItemList}"
                                DisplayMemberPath="{Binding Path=Name}"
                                DataMemberBinding= "{Binding Path=myReport.VisitItem/Item}"
                                 >

however the gridviewcomboboxcolumn is not working, it is blank when loaded, and after selection and lost focus, it returns to blank.

anything wrong with the binding code? i am trying not to use code behind as I am using mvvmlight. Tks.

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 05 Jul 2012, 06:19 AM
Hi Neo,

I would recommend you to run through this article for a reference. 

Kind regards,
Maya
the Telerik team

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

0
Neogeo
Top achievements
Rank 1
answered on 05 Jul 2012, 06:49 AM
Yes I have tried to bind the ItemsSource in Code behind but same behavior.
0
Neogeo
Top achievements
Rank 1
answered on 05 Jul 2012, 08:50 AM

<telerik:GridViewComboBoxColumn.CellTemplate  >

                                    <DataTemplate>

                                        <StackPanel>

                                            <TextBlock Text="{Binding Path=Item.Name}" />

                                            <TextBlock Text="{Binding Path=Item.LongDescription}"/>

                                            <TextBlock Text="{Binding Path=Item.ShortDescription}"/>

                                            <TextBlock Text="{Binding Path=Item.Code}"/>

 

                                        </StackPanel>

                                    </DataTemplate>

                                </telerik:GridViewComboBoxColumn.CellTemplate>

                                <telerik:GridViewComboBoxColumn.ItemTemplate  >

                                <DataTemplate>

                                    <StackPanel>

                                        <TextBlock Text="{Binding Path=Name}" />

                                            <TextBlock Text="{Binding Path=LongDescription}"/>

                                            <TextBlock Text="{Binding Path=ShortDescription}"/>

                                            <TextBlock Text="{Binding Path=Code}"/>

                                           

                                        </StackPanel>

                                </DataTemplate>

                                </telerik:GridViewComboBoxColumn.ItemTemplate>


Got it working.. 
But wonder why the CellTemplate need to bind to the Item under the collection, but the ItemTemplate need to bind to the prop under for those under under the collection?

Also when I click the combobox button, it turns blank and the height return to normal(non template style) before it drop down the combo, what can be done?

Tks.

BTW, binding to code behind or thru VM does not affect me in this case.
Tags
GridView
Asked by
Neogeo
Top achievements
Rank 1
Answers by
Maya
Telerik team
Neogeo
Top achievements
Rank 1
Share this question
or