UnSelect a gridview selected row programmatically

Hi,

I have selected a grid row using mouse click, i want to unselect it programmatically in typescript.

Thanks,

Dayakar. 


3 Replies

SK Sujith Kumar Rajkumar Syncfusion Team February 1, 2022 09:51 AM UTC

Hi Dayakar, 
 
Greetings from Syncfusion support. 
 
For clearing row selection you can call the Grid’s clearSelection method which will clear all the selected rows from the Grid. Individual row selection cannot be cleared, however you can remove the row selection in the UI level by removing its corresponding selection classes as demonstrated in the below code snippet, 
 
// Button click function 
removeSelection() { 
    var selectedRecords = this.gridObj.getSelectedRowIndexes(); 
    if (selectedRecords.indexOf(2) !== -1) { 
        // The third row selection is removed 
        var tr = this.gridObj.getRowByIndex(2); 
        this.gridObj.selectionModule.addRemoveClassesForRow(tr, false, null, 'e-selectionbackground', 'e-active'); 
    } 
} 
 
We have prepared a sample based on this for your reference. You can find it below, 
 
 
 
Please get back to us if you require any further assistance. 
 
Regards, 
Sujith R 



GA Gabe Altenhofen October 4, 2024 01:59 PM UTC

The problem with this is that once you remove the selection, you have to then click the row twice if you want to re-select it.  I'm trying to do the same thing except with checkbox row selection and after you programmatically remove the selection, the next time you click on it, it fires the deselect event instead of select.



JC Joseph Christ Nithin Issack Syncfusion Team October 10, 2024 11:22 AM UTC

Hi Gabe,


Currently we don’t have built in support to deselect a particular row programmatically. However, we have confirmed the requested requirement as an improvement from our side and logged a feature request for the same as  Provide support to deselect particular row programmatically”. At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision, technical feasibility, and customer interest. And this feature will be included in any of our upcoming releases.


You can now track the status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.    


Feedback Link: https://www.syncfusion.com/feedback/46959/need-to-provide-partial-search-support-for-date-column-in-excel-like-grid-filter


We are moving this thread to solved for now. You can also communicate with us regarding the open features any time using our above Feature Report page or reopen the incident.



Regards,

Joseph I.


Loader.
Up arrow icon