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

GridViewComboBoxColumn supports selectionevent?

9 Answers 236 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jin Hyeok Kim
Top achievements
Rank 1
Jin Hyeok Kim asked on 28 May 2009, 12:53 PM

Hello!

I am having some problems with the GridViewComboBoxColumn .

GridViewComboBoxColumn supports selectionevent? Cannot seek change event.
 I am necessary, change event.
There is what kind of method?

9 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 01 Jun 2009, 07:55 AM
Hi Jin Hyeok Kim,

As I have told you in the e-mail , unfortunately the RadGridView does not support SelectionChangedEvent for the ComboBox column.  However I found a good workaround.
Cells can be easily templated and a user control with a ComboBox within can be placed there. In the code-behind of your user control you may handle selection changed events. Note that this approach does not use the built-in ComboBox column. Let me know if that fits your scenario. also if you need I may prepare for you a sample application, demonstrating this approach.

Best wishes,
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.
0
Erez
Top achievements
Rank 1
answered on 12 Aug 2009, 03:10 PM
Hello,

Could you please provide an example ?

Thanks,

Erez
0
Pavel Pavlov
Telerik team
answered on 17 Aug 2009, 08:16 AM
Hi Erez,

Please find the example attached.

Sincerely yours,
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.
0
Erez
Top achievements
Rank 1
answered on 18 Aug 2009, 05:51 AM

Hello,

Thank you for the sample project.
It was very helpful.

A couple of questions:

1) A possible bug in the oCombo.SelectionBoxItem.
There seems to be a bug in the "oCombo.SelectionBoxItem".
If I select a value from the combo, the SelectionBoxItem still point to the previous
selected object. In contrast, "oCombo.SelectedIndex" point to the index of the right one.

Is this a bug or a by design feature ?

2) Finding the row of the combo.
My grid itemssource uses a DataView.
When the selected event fires, how can I find the row (telerik row\dataview row) in which the combo resides ?
I have tried using DataContext, however when connected to a DataView, the object it points
to is "Telerik.Windows.Controls.ComboBoxEditorSettings" and not the DataView or DataRowView.

Thanks,

Erez

0
Pavel Pavlov
Telerik team
answered on 18 Aug 2009, 08:51 AM

Hello Erez,

On point (1) : This behavior is by design. the Selection changed event fires before the SelectionBoxItem has updated.  So if you need to read the newly selected object, i would recommend to use the SelectedItem property instead ( as demonstrated in the code block below) .

On point (2)
The code block below demonstrates a way to extract the relevant row and data within the SelectionChanged event . It also demonstrates how to read the newly selected item in the combo /form point (1)/

Please replace the following handler in the sample project I sent you in my previous reply:

private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)  
        {  
            GridViewRow parentRow = ((UIElement) sender).ParentOfType<GridViewRow>();  
            object data;  
            if (parentRow != null)  
            {  
                data = parentRow.DataContext;  
                Country selectedCountry = ((RadComboBox) sender).SelectedItem as Country;  
                Debug.WriteLine( "Selected country was: " + selectedCountry.Name);  
            }  
        } 

Sincerely yours,

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.
0
Erez
Top achievements
Rank 1
answered on 18 Aug 2009, 11:41 AM

Thanks allot !

There is a related issue that troubles me and using the info you supplied I came up with a solution.

The issue is that selecting a value from a grid combo box does not commit it.

This causes a problem if I press on a button that performs a save operation, because

the datatable does not reflect the change.

The solution I found was to find the cell and do "CommitEdit" myself.

There is only one problem- when I do so, the combo box arrow disappears.

Any helpful tips ?

code:
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)

{

 

   GridViewCell parentCell = ((UIElement)sender).ParentOfType<GridViewCell>();

   if (parentCell != null)

   {

      parentCell.CommitEdit();

   }
}

0
Pavel Pavlov
Telerik team
answered on 19 Aug 2009, 08:42 AM

Hello Erez,

Here are some tips I hope would be helpful.

First -what happens actually is : When you call CommitEdit , the Editor ( ComboBox) hides and the cell reverts from edit mode to its initial  "display" mode , which means  it uses a TextBlock  instead. Thats why the arrow disappears.

I may suggest to try setting the GridViewCell.Value property. Implementing INotifyPropertyChanged on your business object (Person in our example) may also be helpful.

Greetings,

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.
0
Erez
Top achievements
Rank 1
answered on 20 Aug 2009, 02:44 PM
I appreciate the tips

Not sure that the "GridViewCell.Value" will do the trick, however INotifyPropertyChanged is already implemented
by DataView (DataRowView to be exact).

Can I mimic by anyway the textbox\combo box logic-
is there any way to simulate a click on the cell to make the combo box appear ?

Thanks,

Erez
0
Pavel Pavlov
Telerik team
answered on 21 Aug 2009, 08:05 AM
Hello Erez,

You may open a support ticket and send me your project attached . I 'll gladly modify it to gain the desired behavior.

Kind regards,
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
Jin Hyeok Kim
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Erez
Top achievements
Rank 1
Share this question
or