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

How to keep one row always selected

I am using selection mode single and want to always have one row selected. I have persistSelection: true on selectionSettings but when I have a row already selected and click on another row, it does not select the new row. There are no rows selected. How do I select rows properly with persistSelection true?

3 Replies

PS Pavithra Subramaniyam Syncfusion Team February 11, 2019 10:11 PM

Hi Ryan, 

Greetings from Syncfusion. 

Query: I have a row already selected and click on another row, it does not select the new row. There are no rows selected. 

We have analyzed your query and for your requirement, multiple type selection or checkbox selection has to be enabled to use the persistSelection property by default. So in the below sample, we have achieved your requirement by using the rowSelecting method of the grid to have only one row selected. Please refer to the below sample for your reference, 

Code Example:  

[.html] 
... 
rowSelecting(args){ 
      if(this.gridInstance.getSelectedRecords().length){ 
        this.gridInstance.clearSelection(); 
      } 
    } 
... 

Sample               : https://stackblitz.com/edit/react-zylwjt?file=index.js  


Please get back to us for further assistance. 

Regards,  
Pavithra S. 
 



RN Ryan Ngoh February 12, 2019 09:06 AM

Thanks.


PS Pavithra Subramaniyam Syncfusion Team February 12, 2019 08:17 PM

Hi Ryan,  

Thanks for your update.  

Please contact us if you need any further assistance. As always, we will be happy to assist you.  

Regards,  
Pavithra S. 


Loader.
Live Chat Icon For mobile
Up arrow icon