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

Bound GridViewCheckBoxColumn to update datasource on PropertyChanged/CheckChanged

5 Answers 425 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Red
Top achievements
Rank 1
Red asked on 27 Apr 2010, 04:13 AM
Hi,

I have a bound GridViewCheckBoxColumn in my RadGridView. It is bound to an object that properly implements INotifyPropertyChanged etc.

My checkbox column updates the state of the object by "turning it on" such that when it's turned on, another field has it's value set.

However, the binding on the checkbox column only updates on Validation (i.e. leave cell, or row, or grid). I want it to occur sooner on PropertyChanged of the CheckBox.IsChecked property. In a regular winforms databinding scenario this would simply involve setting the DataSourceUpdateMode on the binding to OnPropertyChanged (default is OnValidation).

How can we get at the column/cell binding? Or is there already a property that I'm missing that wraps this functionality up?

Cheers,
Andrew.

5 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 30 Apr 2010, 09:19 AM
Hi Red,

In this case you can handle the ValueChanged event and call EndEdit method. Here is a sample:

void radGridView1_ValueChanged(object sender, EventArgs e)
{
    RadCheckBoxEditor editor = sender as RadCheckBoxEditor;
    if (editor != null)
    {
        this.radGridView1.EndEdit();
    }
}

I hope it helps.

All the best,
Jack
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
Red
Top achievements
Rank 1
answered on 30 Apr 2010, 07:30 PM
Jack,

Maybe it's because I'm using version 2009.1.9.316. The sender of the ValueChanged event is the cell element (that is, in the case of that particular column - GridCheckBoxCellElement).

I had a little trouble getting to the specific editor for a CellElement - how can we do this?

But I resolved it with the following:

        private void itemsGridView_ValueChanged(object sender, EventArgs e)  
        {  
            if (sender is GridCheckBoxCellElement)  
            {  
                var cell = sender as GridCheckBoxCellElement;  
                if (cell.IsEditMode)  
                {  
                    cell.GridControl.EndEdit();  
                }  
            }  
        } 

Are we sure that there's not a way to get at the Property Binding to override some of these settings?

Cheers,
Andrew.
0
Jack
Telerik team
answered on 05 May 2010, 11:57 AM
Hello Red,

Yes, this is because you are using an old version of RadControls. I recommend that you try our latest release - Q1 2010 SP1. It contains many new features. We will appreciate your feedback. 

There is no setting which will change the updating behavior, you have to handle the event.

Best wishes,
Jack
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
Orit Amoyal
Top achievements
Rank 1
answered on 30 Jul 2012, 06:51 AM
Hi,
I have the same problem:
Im using a RadTreeListView with  GridViewCheckBoxColumn as 1st column.
My problem is that property changed event is fired only when row looses focus.
Im trying to use your solution - add ValueChanged event handler to my RadTreeListView but apperently there is no such property.
Im using 2012 release (dll version: 2012.2.709.1040).
Can you help me with this issue?
Or, maybe there is another solution for my problem.

Thanks,
Orit
0
Jack
Telerik team
answered on 30 Jul 2012, 03:33 PM
Hi Orit,

We do not have a RadTreeListView control in our WinForms controls suite. I suppose that you are speaking about the WPF control with this name. If this is true, please direct your question to the appropriate forum. 
 
All the best,
Jack
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Red
Top achievements
Rank 1
Answers by
Jack
Telerik team
Red
Top achievements
Rank 1
Orit Amoyal
Top achievements
Rank 1
Share this question
or