CurrentCellValidated event

HI,

The CurrentCellValidated event is not firing when I am using a checkbox column. It works for the text and the numeric columns.

Any clue?

Kim

          

12 Replies

AR Arulpriya Ramalingam Syncfusion Team March 2, 2020 08:57 AM UTC

Hi Kim, 
 
Thank you for your interest in Syncfusion products. 
 
As per the GridControl current behavior, the CurrentCellValidating and CurrentCellValidated events will be invoked after the current cell is deactivated to move to another cell. It behaves same for all the celltypes and we suspect that you are using the CurrentCellValidateString event to check the value in the cell when the cell is edited at run time. So, we would suggest that you to use the CheckBoxClick event to notify the check state change of the checkbox cell before moving the current cell. Please make use of below code. 
 
Example code 
 
//Event subscription. 
gridControl1.CheckBoxClick += GridControl1_CheckBoxClick; 
 
//Event customization 
private void GridControl1_CheckBoxClick(object sender, GridCellClickEventArgs e) 
{ 
   //Code to perform your behavior. 
} 
 
Please get back to us, if we misunderstood your requirement. 
 
Regards, 
Arulpriya 



KD Kim Dobranski March 5, 2020 06:31 PM UTC

I have a row with a check box column, I click the column to change the state. If I move off the cell or move off the row, the event is still not firing.  


AR Arulpriya Ramalingam Syncfusion Team March 6, 2020 09:38 AM UTC

Hi Kim, 
 
Thank you for the update. 
 
We suspect that you have added a checkbox in the header cell to check or uncheck all the rows in the grid. If yes, we have created a simple demo to achieve your scenario by using the CheckBoxClick event. Please refer to the attached sample and let us know the exact use case, if we misunderstood the scenario. So that, we could analyze further to provide you a better solution at the earliest. 
 
Example code 
 
gridControl1.CheckBoxClick += GridControl1_CheckBoxClick; 
private void GridControl1_CheckBoxClick(object sender, GridCellClickEventArgs e) 
{ 
    
    string check = cellValue.ToString(); 
    if (check == "0") 
        for (int i = 1; i <= gridControl1.RowCount; i++) 
        { 
            gridControl1[i, 3].CellValue = "1"; 
            gridControl1.InvalidateRange(GridRangeInfo.Cell(i, 3)); 
        } 
    else 
        for (int i = 1; i <= gridControl1.RowCount; i++) 
            gridControl1[i, 3].CellValue = "0"; 
} 
 
 
Regards, 
Arulpriya 



KD Kim Dobranski March 9, 2020 03:59 AM UTC

NO I do not have it in the HEADER CELL

I have a bound GRIDCHECKBOXCOLUMN  and when I CLICK THE CHECK BOX in one of the bound rows the CurrentCellValidated event IS NOT FIRING.  All the other changes to any other cell fires the event but not when the change the value of the GRIDCHECKBOXCOLUMN.

The underlying bound object is changed with the new value as expected but the CurrentCellValidated  EVENT doesn't fire.






AR Arulpriya Ramalingam Syncfusion Team March 9, 2020 08:58 AM UTC

Hi Kim, 
 
Thank you for the update. 
 
As we updated earlier, the CurrentCellValidated event will be triggered whenever the editing for the cell is completed or the current cell is moved or the Validate() method of current cell is invoked manually in the sample level. We suspect that you need to invoke the CurrentCellValidated event whenever a check box is clicked. If yes, we would suggest that you to move the currentcell the checkbox clicked cell and validate the cell by using the Validate() method of GridCurrentCell. Please make use of the below code and let us know the code that we are missing to reproduce issue at our, if we misunderstood the requirement. 
 
Example code 
 
private void GridControl1_CheckBoxClick(object sender, GridCellClickEventArgs e) 
{ 
    //To move the current cell. 
    gridControl1.CurrentCell.MoveTo(e.RowIndex,e.ColIndex); 
    //To invoke the CurrentCellValidated event. 
    gridControl1.CurrentCell.Validate(); 
} 
 
 
Regards, 
Arulpriya 



KD Kim Dobranski March 11, 2020 03:45 AM UTC

I am using the sfDataGrid, not the GridControl. My bad. How can i get it working on the sfDataGrid?  



SS Susmitha Sundar Syncfusion Team March 11, 2020 04:49 PM UTC

Hi Kim, 
 
Thank you for your update. 
 
By default, SfDataGrid.CurrentCellValidating event not raised for GridCheckBoxColumn (non editable column). You can use the built-in validation for this. Please refer the below ug link for more details, 
 
 
Can you please explain your requirement we will check the possibilities to achieve this? 
 
Regards, 
Susmitha S 



KD Kim Dobranski March 11, 2020 06:44 PM UTC

Hi,

When the user clicks the checkbox I need to trigger an event so I can update Textbox fields on the form. For example, I have a textbox on a form that shows the Total Tax payable. When the users selects the checkbox in the grid, it determines if the line is taxable or not. When a used clicks (or unclicks) the "Taxable" check box for a row in the grid I need to recalculate the Total Tax for the textbox on the form. I need some event to fire when the value of the checkbox changes.




SS Sampathnarayanan Sankaralingam Syncfusion Team March 12, 2020 02:26 PM UTC

Hi Kim,    
     
Thank you for your update.     
    
You can achieve your requirement to get the changed value in GridCheckBoxColumn by using View.RecordPropertyChanged.    
    
Please find the below code snippet and sample link.   
   
this.sfDataGrid1.View.RecordPropertyChanged += View_RecordPropertyChanged;   
   
private void View_RecordPropertyChanged(object sender, PropertyChangedEventArgs e)   
{   
    var record = (sender as OrderInfo).IsClosed;   
   
    //You can customize here.   
}     
    
     
 
Please let us know, if you require further assistance on this.    
     
Regards,    
Sampath Narayanan.S 



KD Kim Dobranski March 12, 2020 04:44 PM UTC

Not working. Still doesn't fire this event either.  Is it because I am adding the column via the designer?


KD Kim Dobranski March 12, 2020 06:49 PM UTC

Hi you can close this and disregard. I have decided to go with a different grid control.


SS Susmitha Sundar Syncfusion Team March 13, 2020 01:29 PM UTC

Hi Kim, 
 
Sorry for the inconvenience caused. 
 
By default, SfDataGrid.View.Record property changed raised when you change the record even you create the columns through designer or code-behind. We suspect that you did not implement the INotifyPropertyChanged interface for your model class. Please check the below image, 
 
public class OrderInfo : INotifyPropertyChanged 
{ 
    bool ischecked; 
    int orderID; 
    string customerId; 
    string country; 
    string customerName; 
    string shippingCity; 
    public int OrderID 
    { 
        get { return orderID; } 
        set 
        { 
            orderID = value; 
            OnPropertyChanged("OrderID"); 
        } 
    } 
    public string CustomerID 
    { 
        get { return customerId; } 
        set 
        { 
            customerId = value; 
            OnPropertyChanged("CustomerID"); 
        } 
    } 
    public string CustomerName 
    { 
        get { return customerName; } 
        set 
        { 
            customerName = value; 
            OnPropertyChanged("CustomerName"); 
        } 
    } 
    public string Country 
    { 
        get { return country; } 
        set 
        { 
            country = value; 
            OnPropertyChanged("Country"); 
        } 
    } 
    public string ShipCity 
    { 
        get { return shippingCity; } 
        set 
        { 
            shippingCity = value; 
            OnPropertyChanged("ShipCity"); 
        } 
    } 
 
    public bool IsChecked 
    { 
        get { return ischecked; } 
        set 
        { 
            ischecked = value; 
            OnPropertyChanged("IsChecked"); 
        } 
    } 
 
    public event PropertyChangedEventHandler PropertyChanged; 
    public void OnPropertyChanged(string PropertyName) 
    { 
        if (PropertyChanged != null) 
            PropertyChanged(this, new PropertyChangedEventArgs(PropertyName)); 
    } 
 
    public OrderInfo(bool ischecked,int orderId, string customerName, string country, string customerId, string shipCity) 
    { 
        this.IsChecked = ischecked; 
        this.OrderID = orderId; 
        this.CustomerName = customerName; 
        this.Country = country; 
        this.CustomerID = customerId; 
        this.ShipCity = shipCity; 
    } 
} 
 
 
 
 
Please check the sample and let us know if you need further assistance on this. 
 
Could you please share the reason for choosing another grid control? We will make every effort to provide the solution for all your queries. 
 
Regards, 
Susmitha S 


Loader.
Up arrow icon