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

Double Binding ComboBoxColumn

4 Answers 110 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Johan Van der Galien
Top achievements
Rank 1
Johan Van der Galien asked on 14 Apr 2010, 12:45 PM

I use Silverlight 3, Windows 2003 Server for hosting, RadControls Q1 2010.

I have 5 ComboBox en 3 data columns in a GridView:

<grid:RadGridView x:Name="RadGridView1" local:GridViewCommandRow.IsEnabled="true" CanUserDeleteRows="True" CanUserInsertRows="True" AutoGenerateColumns="False">
                            <grid:RadGridView.Columns>
                                <grid:GridViewComboBoxColumn x:Name="TransactieMethodesCBC" DisplayIndex="0"  Header="Transactiemethodes" DataMemberBinding="{Binding Omschrijving, Mode=OneWay}" DisplayMemberPath="Omschrijving" SelectedValueMemberPath="Omschrijving" />
                                <grid:GridViewComboBoxColumn x:Name="PeriodesCBC" DisplayIndex="1" Header="Periodes" DataMemberBinding="{Binding Omschrijving, Mode=OneWay}" DisplayMemberPath="Omschrijving" SelectedValueMemberPath="Omschrijving" />
                                <grid:GridViewDataColumn Header="Eerste datum" DisplayIndex="2" DataMemberBinding="{Binding Eerste_datum, Mode=TwoWay}" />
                                <grid:GridViewDataColumn Header="Frequentie" DisplayIndex="3" DataMemberBinding="{Binding Frequentie, Mode=TwoWay}" />
                                <grid:GridViewComboBoxColumn x:Name="TermijnenCBC" DisplayIndex="4" Header="Termijnen" DataMemberBinding="{Binding Eenheid, Mode=OneWay}" DisplayMemberPath="Eenheid" SelectedValueMemberPath="Eenheid" />
                                <grid:GridViewComboBoxColumn x:Name="VerplichtingenCBC" DisplayIndex="5" Header="Verplichtingen" DataMemberBinding="{Binding Omschrijving, Mode=OneWay}" DisplayMemberPath="Omschrijving" SelectedValueMemberPath="Omschrijving" />
                                <grid:GridViewDataColumn Header="Bedragen" DisplayIndex="6" DataMemberBinding="{Binding Bedragen, Mode=TwoWay}" />
                                <grid:GridViewComboBoxColumn x:Name="RekeningmutatiesCBC" DisplayIndex="7" Header="Rekeningmutaties" DataMemberBinding="{Binding Omschrijving, Mode=OneWay}" DisplayMemberPath="Omschrijving" SelectedValueMemberPath="Omschrijving" />
                                <grid:GridViewDataColumn Header="Omschrijvingen" DisplayIndex="8" DataMemberBinding="{Binding Omschrijvingen, Mode=TwoWay}" />
                            </grid:RadGridView.Columns>
                        </grid:RadGridView>

Binding the itemsource to the ComboBoxColumn is done like:

((GridViewComboBoxColumn)this.RadGridView1.Columns[0]).ItemsSource = App.MijnTransactieMethodes;
                ((GridViewComboBoxColumn)this.RadGridView1.Columns[1]).ItemsSource = App.MijnPeriodes;
                ((GridViewComboBoxColumn)this.RadGridView1.Columns[4]).ItemsSource = App.MijnTransactieEenheden;
                ((GridViewComboBoxColumn)this.RadGridView1.Columns[5]).ItemsSource = App.MijnVerplichtingen;
                ((GridViewComboBoxColumn)this.RadGridView1.Columns[7]).ItemsSource = App.MijnRekeningMutaties;

Binding the other (Data) columns to itemsource is done like:

this.RadGridView1.ItemsSource = App.FinancieleVerplichtingenGridView;

Problems:
-ComboBoxes are filled with items but there is no default value. ComboBox initially stays empty!
-The selected item is only shown when the ComboBoxCell has focus, when focus is lost cell is empty again!

Question: Can I bind a ComboBoxColumn, for the display list, to an ItemsSource AND also to the GridView ItemsSource (Double Bind)? In a way that I have a list in the ComboBoxes and that the selected value is transferred by TwoWay binding to the GridView ItemsSource?

Kind regards,

Johan van der Galien.

4 Answers, 1 is accepted

Sort by
0
Johan Van der Galien
Top achievements
Rank 1
answered on 14 Apr 2010, 01:21 PM
Excuses for the double postings. But I always got: Oops ...  There was a problem on our server! after posting so I retried 4 or 5 times.
0
Pavel Pavlov
Telerik team
answered on 14 Apr 2010, 04:22 PM
Hi Johan Van der Galien,

I am afraid that the scenario requires a bit more than just a binding .
The attached example demonstrates a similar case where the rows of a grid are being populated by a combo box .
Please use it as a starting point.

Sincerely yours,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Johan Van der Galien
Top achievements
Rank 1
answered on 15 Apr 2010, 03:27 PM

Mark this as still not answered!

ComboBoxes are filled with items but there is no default value. ComboBox initially stays empty! Not fixable with your sample code!

Question: Can I bind a ComboBoxColumn, for the display list, to an ItemsSource AND also to the GridView ItemsSource (Double Bind)? In a way that I have a list in the ComboBoxes and that the selected value is transferred by TwoWay binding to the GridView ItemsSource? Not fixable with your sample code!

In your sample code ItemsSource of RadComboBox and GridView are of the same type (ObservableCollection<Person>). This is not realistic, not for a real life application! What I and my co-workers want are two different object types, this could be done by a RadComboBox (ItemsSource object A) transferring its selected items to another column (ItemsSource object B). Ideally A comes from a LINQ to SQL database by SELECT and with B all CRUD operations should be possible.

How can we do that? Datatemplates? Please give again some sample code.

I hope I made my self clear!

If not do not hesitate to ask!

Kind regards,

Johan van der Galien.

 

0
Pavel Pavlov
Telerik team
answered on 21 Apr 2010, 12:07 PM
Hello Johan Van der Galien,

Please excuse me for the late answer,  it seems I have misinterpreted the question.
I am attaching a sample of the typical application of the GridVIewComboBox column  where a value selected in the combobox is updated to the ItemsSource of RadGridView.

Now on the problem : Usually the reason for the values to not appear in display mode ( and appear in edit mode only)  is that  RadGridView can not match the value in the cell with a value in the ItemsSource of the GridViewComboBox column . ( the Equals method is used internally ) .

If the sample attached is not of much help to you , please paste me the implementation of your business objects with some details on the expected behavior  and I will try to prepare a working sample for you .

Best wishes,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Johan Van der Galien
Top achievements
Rank 1
Answers by
Johan Van der Galien
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Share this question
or