Unable to save value when checking or unchecking the checkbox directly in GridCheckBoxColumn - From 183888

The second incident, entering the accounts menu option, in the upper bar, we can mark or unmark the checkbox directly and click on another row. but this does not update the data. To do it I have to check or uncheck the checkbox and then pass the focus to another control of that line, so if I can save the line.



1 Reply 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team August 9, 2023 06:55 PM UTC

Hi Ricardo,

You are saving the data using the RowValidated event in SfDataGrid. But GridCheckBoxColumn is a non-editable column. We have only executed the check or uncheck the CheckBox control directly in GridCheckBoxColumn. Also, RowValidated and RowValidating events are not triggered for GridCheckBoxColumn. So, the reported problem occurs but the reported scenario is not an issue and is expected behavior.

However, you can overcome this by marking the current row-validated flag as false using ValidationHelper.SetCurrentRowValidated method in CurrentCellValueChanged event as shown below,

// Event customization

private void OngvAccountsCurrentCellValueChanged(object sender, CurrentCellValueChangedEventArgs e)

{

    int columnIndex = this.gvAccounts.ResolveToGridVisibleColumnIndex(e.RowColumnIndex.ColumnIndex);

 

    //We are enabling the RowValidating event if the changes happen in GridCheckBoxColumn

    if (this.gvAccounts.Columns[columnIndex].CellType == "CheckBox")

    {

        this.gvAccounts.GetValidationHelper().SetCurrentRowValidated(false);

    }

}


KB Link: https://support.syncfusion.com/kb/article/5634/how-to-fire-rowvalidating-event-for-gridcheckboxcolumn-in-sfdatagrid-in-wpf-

Find the modified sample in the attachment.

Regards,
Vijayarasan S

If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Attachment: Modified_Sample_94d83c38.zip

Marked as answer
Loader.
Up arrow icon