Problem to catch checked change event from GridViewCheckBoxColumn type of column

6 posts, 0 answers
  1. Auvo
    Auvo avatar
    43 posts
    Member since:
    Jul 2011

    Posted 23 Sep 2011 Link to this post

    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

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 23 Sep 2011 Link to this post

    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 >>

  3. Ricardo
    Ricardo avatar
    2 posts
    Member since:
    Dec 2007

    Posted 12 Jul 2012 Link to this post

    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.

  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Jul 2012 Link to this post

    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.

  5. Peer
    Peer avatar
    1 posts
    Member since:
    Aug 2020

    Posted 08 Jan in reply to Dimitrina Link to this post

    There will be no fix for that?

  6. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2644 posts

    Posted 11 Jan Link to this post

    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/.

Back to Top