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

Update another cell using CreateCellEditElement in current cell

3 Answers 100 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Stavros
Top achievements
Rank 1
Stavros asked on 10 Oct 2016, 02:17 PM

Hello, lets say that we are using the radGridView and we have some columns like above:

First Name, Last Name, Sex, Age, Type1, Type2

The column "Type1" has a custom editor that implements the classes:

CreateCellElement and CreateCellEditElement using a combobox for selection of value.

Also i must clarify that column "Type2" depents on column's "Type1" value

So how can we clear in the current row the column's "Type2" value when the value of column "Type1" is changed through the CreateCellEditElement?

 

Thanks

3 Answers, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 11 Oct 2016, 10:46 AM
Hi Stavros,

I am not fully familiar with your specific setup, but generally, in the scenario you have explained, you can call PropertyChanged of Type2 in the setter of Type1. This way, when you have set the value of Type1, the value of Type2 will be updated in the RadGridView. I have attached a sample project for your reference. It does not use a custom column but the approach should be the same for you. Please check the "Club" object implementation. 

Regards,
Stefan Nenchev
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Stavros
Top achievements
Rank 1
answered on 11 Oct 2016, 03:11 PM

Nice, this does do the job, when i change the value of column's "Type1" and focus somewhere else, the onrowedit event is fired and the value of column's "Type2" is cleared.

Now i am thinking something more complex in the above implementation, to do it more dunamically.

Is possible to clear column's "Type2" value when the selected index of combobox of custom editor of column's "Type1" is changing before onrowedit is fired?

0
Stefan Nenchev
Telerik team
answered on 13 Oct 2016, 10:49 AM
Hello Stavros, 

As far as I understand your requirement, you would like to change the value of the second property when the selection is changed in the RadComboBox. Is this correct?

If this is the case, you can attach to the SelectionChanged event of the RadComboBox and call CommitEdit on the RadGridView:

public MainWindow()
       {
           InitializeComponent();
           this.AddHandler(RadComboBox.SelectionChangedEvent, new SelectionChangedEventHandler(onSelectionChanged));
       }
 
private void onSelectionChanged(object sender, SelectionChangedEventArgs e)
       {
           if (e.RemovedItems.Count > 0)
           {
               this.pilotsGrid.CommitEdit();
           }
       }

I have added another sample that reflects your setup more precisely. 

Regards,
Stefan Nenchev
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Stavros
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Stavros
Top achievements
Rank 1
Share this question
or