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
close icon

Delete item in the toolbar

Hello, 

Once the user has deleted ONE row, not multiple rows, automatically selects the next one. I don't want this to happend. How can I fix it? 

Looking forward to hearing from you, 

Ane

5 Replies

PS Pavithra Subramaniyam Syncfusion Team January 31, 2019 12:31 PM UTC

 
Greetings from Syncfusion. 
 
Query: Once the user has deleted ONE row, not multiple rows, automatically selects the next one. I don't want this to happend 
 
We have analyzed your query and we can achieve your requirement by using the actionComplete and rowSelecting events for Nomal edit and for Batch edit we suggest to use the batchDelete event with clearRowSelection to clear the selected row after the delete operation. Please refer to the below sample and documentation for your reference, 
 
Code Example:  
 
[.ts]   [Normal edit] 
... 
complete(args) { 
        if(args.requestType == 'delete'){ 
          this.isDeleted = true; 
        } 
    } 
     
    selecting(args) { 
      if(this.isDeleted) { 
      args.cancel = true; 
      this.isDeleted = false; 
      } 
    }  
... 
 
 
                                https://ej2.syncfusion.com/documentation/api/grid/#rowselecting  
 
[.ts]  [Batch edit] 
... 
delete(args){ 
      this.grid.selectionModule.clearRowSelection(); 
    } 
... 
 
 
                                https://ej2.syncfusion.com/documentation/api/grid/selection/#clearrowselection  
 
Please get back to us for further assistance. 
 
Regards, 
Pavithra S. 



AN Ane February 1, 2019 08:23 AM UTC

Hello, 

I have used Normal Edit but it's not working. 

(actionComplete)="onActionComplete($event)" (rowSelected)='onRowSelectionDelete($event)'

onActionComplete(event) {
if (event.requestType === 'delete') {
this.isDeleted = true;
}
}

onRowSelectionDelete(event: any) {
this.gridDelete.toolbarModule.enableItems(['grid_1625883774_0_delete'], true);
if (this.isDeleted) {
event.cancel = true;
this.isDeleted = false;
}
}

Looking forward to hearing from you, 

Ane


PS Pavithra Subramaniyam Syncfusion Team February 1, 2019 09:25 AM UTC

Hi Ane, 

Thanks for your update. 

In your code you have used “rowSelected” instead of “rowSelecting” event which is the cause of the issue. Please refer to the below code example and sample link for more information. 

[component.html] 
<ejs-grid #normalgrid [dataSource]='data' [editSettings]='editSettings' [toolbar]='toolbar' (actionComplete)="onActionComplete($event)" (rowSelecting)='onRowSelectionDelete($event)'> 
            <e-columns> 
              .   .  
            </e-columns> 
        </ejs-grid> 
 

[component.ts] 
@Component({ 
    selector: 'control-content', 
    templateUrl: 'normal-edit.html', 

}) 
export class NormalEditComponent implements OnInit { 
     .    .  
    onActionComplete(event) { 
    if (event.requestType === 'delete') { 
      this.isDeleted = true; 
   
 

onRowSelectionDelete(event: any) { 
    if (this.isDeleted) { 
      event.cancel = true; 
      this.isDeleted = false; 
   
 
 


Please get back to us if you need any further assistance. 

Regards, 
Pavithra S. 



AN Ane February 1, 2019 10:18 AM UTC

Thank you!



PS Pavithra Subramaniyam Syncfusion Team February 1, 2019 10:49 AM UTC

Hi Ane,  

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