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
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 >>
In my case the Checkbox is Unbound and used to alter the content of another cell.
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.
There will be no fix for that?
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/.