cancel selection

Hi,

I've two questions:

1. I need cancel a selection if selected row doesn't meet some requeriments, in my case. I only can selec rows with same ProductoElectricidad

In event row selecting, I check this condition

rowSelecting(argsRowSelectingEventArgs) {
    const selected = this.grid.getSelectedRecords() as any;
    const mismoProd = selected.everyx => x.idProductoElectricidad === (args.data as any).idProductoElectricidad )
    if (mismoProd) {
      this.productosSeleccionados.push(args.data);
    } else {
      args.cancel = true;
      this.toastr.warning('Solo se puede seleccionar familias con el mismo tipo de producto de electricidad''Aviso');
    }
    debugger
  }

args.cancel is fired but the grid appear with check selected. In the image the first row must be unchecked


2. How can I hidde the header check for check/uncheck all

Thanks

1 Reply 1 reply marked as answer

TS Thiyagu Subramani Syncfusion Team March 12, 2021 08:38 AM UTC

Hi Manolo, 

Thanks for contacting Syncfusion support. 

Query -1: I need cancel a selection if selected row doesn't meet some requirements, in my case. I only can select rows with same ProductoElectricidad. 
 
Based on your query we suspect that you want to prevent the row selection if the selected row does not meet some requirements. So, we have prepared sample based on your code example but we did not face the reported issue at our end. 

Please refer to the below code. 

rowSelecting(args) { 
    const selected = this.grid.getSelectedRecords() as any; 
    //checked selected row’s ShipCountry data to the args data 
    const mismoProd = selected.every(x => x.ShipCountry === (args.data as any).ShipCountry) 
    if (mismoProd) { 
      this.productosSeleccionados.push(args.data); 
    } else { 
      args.cancel = true; 
    } 
  } 

Query -2: How can I hide the header check for check/uncheck all 
 
We have achieved your requirement by defining display as none for required checkbox element in dataBound event. please refer to the below code. 

dataBound(args){ 
    (this.grid.getHeaderContent().getElementsByClassName('e-checkbox-wrapper')[0] as any).style.display = "none" 
  } 


For more reference please refer to the below sample for both queries 


If still facing the issue, please share below details then only we provide the appropriate solution as soon as possible. 

1. Share issue reproducing sample or reproduce the issue in above provide sample. 

2. Syncfusion package version. 

3. If possible, share complete Grid code file. 

4. Are you using any customized style or script in your application 

Regards, 
Thiyagu S 


Marked as answer
Loader.
Up arrow icon