How to detect deselected rows

I have some buttons etc. on my page which should only be active if a row is selected. My first thought was to have them disabled when the page loads, and then handle the grid's rowSelected event to enable them. However, there are some situations where grid rows will be deselected. For instance when I update the grid's datasource and call grid.refreshContent(), or the situation I cannot find any way to handle - the user simply presses the excape key. Does the grid have any way to detect when a row is deselected?

1 Reply

VN Vignesh Natarajan Syncfusion Team April 25, 2018 01:40 PM UTC

Hi Joakim, 
 
Thanks for using Syncfusion products. 
 
We have analyzed your query (“detect deselected rows”) and we suspect that you want to disable the button when the record is deselected. We suggest you to achieve your requirement using rowDeselected and actionComplete event of the Grid.  
 
Refer the below code snippet 
 
allowPaging: true, 
        rowDeselected: function(args) {     // will be triggered when row is deselected 
            alert("de") 
        }, 
    actionComplete: function(args) {  // when refreshContent is called requesttype will be refresh 
        if (args.requestType == "refresh") {   // will be requestType when dataSpurce is updated. 
            if (this.getSelectedRecords().length == 0)  // will check any records is selected 
                alert("deselected");  // you can perform your action here 
        } 
    }, 
 
 
Refer our help documentation for your reference 
 
 
Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon