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

Single selection of row using checkbox not working in grid

Hi,
     
     I am using grid for single selection of row at any point i.e only one row should be selected,if another row is selected, previous row should be unselected.For this purpose i am using type as single in selection setting property,But Not working as expected.

Or if any another way to do this functionality please suggest me. 

Thank you.

3 Replies

PS Pavithra Subramaniyam Syncfusion Team April 5, 2019 08:57 AM UTC

Hi Goutham, 
 
Greetings from Syncfusion. 
 
By default Checkbox selection is used for multiple Grid row selection. So if you want to maintain only one selected row, You can achieve your requirement by using the “rowSelecting” event of Grid component. Please refer to the below code example, documentation link and sample link. 
 
[component.ts] 
@Component({ 
    selector: 'app-root', 
    templateUrl: ' <ejs-grid #grid [dataSource]='data' allowPaging='true' [allowSelection]="true" [editSettings]='editSettings' (rowSelecting)='rowSelecting($event)'> 
        <e-columns> 
            <e-column type='checkbox' width='50'></e-column> 
             .   .  . 
        </e-columns> 
    </ejs-grid> ', 
}) 
export class AppComponent { 
    .   .  . 
    rowSelecting(e){ 
      if(this.grid.getSelectedRecords().length){  
        this.grid.clearSelection();  
      }  
    } 
} 
  
                              https://ej2.syncfusion.com/angular/documentation/api/grid/#getselectedrecords 
                              https://ej2.syncfusion.com/angular/documentation/api/grid/#clearselection 
 
 
Please get back to us if you need further assistance. 
 
Regards, 
Pavithra S. 



GO Goutham April 5, 2019 10:02 AM UTC

Thank you for quick response.


PS Pavithra Subramaniyam Syncfusion Team April 5, 2019 10:27 AM UTC

Hi Goutham, 
 
Thanks for your update. 
 
Please get back to us if you have any concern. 
 
Regards, 
Pavithra S. 


Loader.
Live Chat Icon For mobile
Up arrow icon