We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Check if cell is empty

HelloHow to check if cell is empty after loosing focus?The problem I'm facing with is saving values from programatically binded gridgrouping control. The one of fields should not be empty (not null) and I need to check and/or inform user to check specific field before saving.

1 Reply

MG Mohanraj Gunasekaran Syncfusion Team May 8, 2017 01:54 PM UTC

Hi Josip,  
 
Thanks for using Syncfusion products.  
 
Query 
Solution 
How to check if cell is empty after loosing focus? 
In order to validate the cell value when losing the focus, you can use the SetError method in CurrentCellValidating event. Please refer to the below code example, 
 
Code example 
this.gridGroupingControl1.TableControl.CurrentCellValidating +=TableControl_CurrentCellValidating; 
 
void TableControl_CurrentCellValidating(object sender, CancelEventArgs e) 
{ 
    GridCurrentCell currentCell = this.gridGroupingControl1.TableControl.CurrentCell; 
    GridTableCellStyleInfo style = this.gridGroupingControl1.TableControl.GetTableViewStyleInfo(currentCell.RowIndex, currentCell.ColIndex); 
    if (String.IsNullOrEmpty(currentCell.Renderer.ControlText)) 
    { 
        currentCell.SetError("Please enter the valid data"); 
    } 
} 
 
Please refer the below UG link: 
The problem I'm facing with is saving values from programatically binded gridgrouping control. The one of fields should not be empty (not null) and I need to check and/or inform user to check specific field before saving. 
By default, the GridGroupingControl does not have the support to validate the cell value while updating the value programmatically because you can check the value using String.IsNullOrEmpty method when you update the value programmatically. If we misunderstood your scenario, please provide your updating details or provide the simple sample to understand your scenario. It will be helpful to provide the solution at the earliest. 
 
 
  
Sample link: GridGroupingCotnrol  
 
Regards,  
Mohanraj G  
 


Loader.
Live Chat Icon For mobile
Up arrow icon