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

[Solved] ComboBoxEditor and itemssource return value

1 Answer 92 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jean-Marc Schellings
Top achievements
Rank 1
Jean-Marc Schellings asked on 22 Jul 2009, 09:22 AM
Hello,

I have a RadGridView which ItemsSource is an object containing other objects containing themselves other objects (I bind my Business Object to the Grid). The "BO" is something like a Customer. The Customer has an address and the address has a type, etc.
So First step, I bind the grid to my BO by setting the ItemsSource = List<Address>

  <telerikGrid:RadGridView x:Name="_gridAddress" AutoGenerateColumns="False" ColumnsWidthMode="Fill">
                    <telerikGrid:RadGridView.Columns>
                        <telerikGrid:GridViewDataColumn UniqueName="TypeAdresse" DataMemberPath="TypeAdresse.Libelle"></telerikGrid:GridViewDataColumn>
 </telerikGrid:RadGridView.Columns>                
                </telerikGrid:RadGridView>

So the BO hierarchy is :

Address -> TypeAddress -> Libelle

No problem, the "Libelle" is correctly shown in the grid.

Now I would like to be able to edit this value. As these values are part of an enumeration, I would like to use a ComboBoxEditor.
At the initialization time, I do :
ComboBoxEditorSettings sett = new ComboBoxEditorSettings();
sett.ItemsSource = listOfTypeAddress;           
sett.DisplayMemberPath = "Libelle";
sett.SelectedValuePath = "id";
(_gridAddress.Columns["TypeAdresse"] as GridViewDataColumn).EditorSettings = sett;

The result is now correct, When I double click or F2 on the cell, the ComboBoxEditor appear and show me the different values.

The problem is that when the value is selected in the ComboBoxEditor and validated, only the "id" (SelectedValuePath) is going to be retreived and be placed in
the BO (Address->TypeAddress->Libelle) as my Grid is bound to it (specified by DataMemberPath)

What I would like is to retreive the selected TypeAddress in the ComboBox and place it as the current TypeAddress in my BO, so the gridview will still display the Libelle.
I tried to implement the CellValidating event, but I cannot figure out how to deal with this problem.

Please Help

Regards

1 Answer, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 27 Jul 2009, 07:42 AM
Hello Jean-Marc ,
I would recommend the following approach:

You have to subscribe to the CellEditEnded  event of the RadGridView.
Within the event you are able to read the updated values the following way:

((GridViewRow)e.Row).Cells[0].Value

You may cast the e.NewData to your business object and manipulate the values of the object by code.

In case this sounds unclear , please give me the classes of your business object and I will gladly prepare a ample for you.

All the best,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Jean-Marc Schellings
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or