Grid custom validation

Hello,

I have a grid with checkbox column.

The grid is inside a form.

I want to verify if at least one checkbox is checked, otherwise, I want to throw an error message, somewhere outside of the grid.

Thank you!




1 Reply

RS Rajapandiyan Settu Syncfusion Team March 14, 2022 11:53 AM UTC

Hi Dana, 
 
Thanks for contacting Syncfusion support. 
 
You can achieve your requirement by using getSelectedRecords method of Grid which returns the currently selected records. 
 
 
 
  btnClick(args) { 
    var selectedRecords = this.grid.getSelectedRecords(); // get the selected records detail 
    if (selectedRecords.length == 0) { 
      // if the selected record length is 0, throw the validation here. 
    } 
  } 
 
 
Note: By default, we are not supposed to use Grid control inside the form element. Because Grid component is not the input element. 
 
Please get back to us if you need further assistance with this. 
 
Regards, 
Rajapandiyan S 


Loader.
Up arrow icon