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 12, 2019 06:11 AM UTC

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 05:06 PM UTC

Thanks.


PS Pavithra Subramaniyam Syncfusion Team February 13, 2019 04:17 AM UTC

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