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

Problem to catch checked change event from GridViewCheckBoxColumn type of column

5 Answers 1187 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Auvo
Top achievements
Rank 1
Auvo asked on 23 Sep 2011, 07:54 AM
Hi,

When I have dynamically added a new column to RadGridView which type is GridViewCheckBoxColumn

radGridView1.Columns.Add(new GridViewCheckBoxColumn() { DataMemberBinding = new Binding("HasOrders"), UniqueName = "HasOrders3", Header = "Has Orders3"
    , AutoSelectOnEdit = true
    , EditTriggers = GridViewEditTriggers.Default | GridViewEditTriggers.CellClick
});

I will get the cheched status from CellEditEnded - event

private void radGridView1_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e)
{
    if (e.Cell.Column.UniqueName == "HasOrders3")
    {
        textBox3.Text = ((CheckBox)e.EditingElement).IsChecked.ToString();
    }
}

But this CellEditEnded - event triggers only when I leave the cell or press enter/tab key.

If I stay on that cell and click the checkbox I cannot catch the cheched change event? How can I do that in?

Regards,
Auvo

5 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 23 Sep 2011, 02:58 PM
Hello Auvo,

 Generally, you can define CellTemplate for a column, add a CheckBox inside and handle its Checked event:

<telerik:GridViewDataColumn DataMemberBinding="{Binding IsChampion}">
                <telerik:GridViewDataColumn.CellTemplate>
                    <DataTemplate>
                        <CheckBox IsChecked="{Binding IsChampion, Mode=TwoWay}" Checked="CheckBox_Checked"/>
                    </DataTemplate>
                </telerik:GridViewDataColumn.CellTemplate>
            </telerik:GridViewDataColumn>

Furthermore, in your particular case,  you could bind the textBox3 Text property directly to the "HasOrders3" bound property. That way once the state of the CheckBox is changed(i.e. the value of "HasOrders3" has changed), the text in the text box will be updated immediately.

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Ricardo
Top achievements
Rank 1
answered on 12 Jul 2012, 10:27 PM
If I use the CheckBox inside solution , how can I know witch row was selected on the handler. 
In my case the Checkbox is Unbound and used to alter the content of another cell.

0
Dimitrina
Telerik team
answered on 13 Jul 2012, 01:33 PM
Hello,

 You could find the parent row for the "checked" CheckBox like so:

private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
    var parent = (sender as CheckBox).ParentOfType<GridViewRow>();
}

Does this work for you?

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Peer
Top achievements
Rank 1
answered on 08 Jan 2021, 11:47 AM

There will be no fix for that?

0
Martin Ivanov
Telerik team
answered on 11 Jan 2021, 06:58 AM

Hello Peer,

This behavior is expected with the RadGridView control. Changing the selected value in the checkbox of the column doesn't automatically commit the cell change, thus you have to trigger it somehow. For example, by pressing another cell. This is why if you want to alter the default behavior you will need to customize the column's setup. One way to do this is to use the Didie's approach from one of the previous replies here.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
GridView
Asked by
Auvo
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Ricardo
Top achievements
Rank 1
Peer
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or