Prevent selection sertain rows based on condition

Hello

I'm using vue grid. 
I'm trying to prevent the selection of specific rows, based on condition.
I found 'rowSelected' and 'rowSelecting' events, but there is no cancel property to prevent them. I ried to use window.event then, but that didn't work.
Can you provide some examples, how to prevent selection of certain rows?

3 Replies 1 reply marked as answer

TS Thiyagu Subramani Syncfusion Team June 5, 2020 05:44 AM UTC

Hi Alex, 

Thanks for contacting Syncfusion support. 

Query:  how to prevent selection of certain rows? 

Based on your query you need to prevent selection for the certain rows in Grid. To achieve your requirement we suggest you to use rowSelecting event of EJ2 Grid.  

In rowSelecting event we can check the condition and avoid the selection by defining args.cancel as true. Please refer to the below code and sample. 

rowSelecting: function(args) { 
      if (args.rowIndex % 2 === 0) { 
        args.cancel = true; 
      } 
    } 

 



Please get back to us, if you need any further assistance. 

Regards, 
Thiyagu S. 


Marked as answer

AB Alex B replied to Thiyagu Subramani June 5, 2020 08:04 AM UTC

Hi Alex, 

Thanks for contacting Syncfusion support. 

Query:  how to prevent selection of certain rows? 

Based on your query you need to prevent selection for the certain rows in Grid. To achieve your requirement we suggest you to use rowSelecting event of EJ2 Grid.  

In rowSelecting event we can check the condition and avoid the selection by defining args.cancel as true. Please refer to the below code and sample. 

rowSelecting: function(args) { 
      if (args.rowIndex % 2 === 0) { 
        args.cancel = true; 
      } 
    } 

 



Please get back to us, if you need any further assistance. 

Regards, 
Thiyagu S. 


Hello Thiyagu S. 

Thanks a lot, that worked to me.


TS Thiyagu Subramani Syncfusion Team June 5, 2020 09:02 AM UTC

Hi Alex,   

Thanks for the update.   

We are happy to hear that your issue is resolved.   

Please get back to us if you need further assistance.   

Regards,   
Thiyagu S.   


Loader.
Up arrow icon