Delete key events

Hi there,
I want perform some additional actions while pressing Del key from keyboard. I also want remove node on delete but want to do something more on it so i need to identify the delete event. How can I achieve this?

1 Reply

SG Shyam G Syncfusion Team September 18, 2018 10:59 AM UTC

Hi Ahman, 
 
Please use commandManager to achieve your requirement while pressing delete key on keyboard. we have created a playground link in which we have deleted the selected node/connector using command manager. Please refer to code example, playground link and help documentation below for your reference. 
 
Code example: 
$("#diagram").ejDiagram({                      
                    commandManager:{ 
                        commands: { 
                            "delete": { 
                                canExecute: function (args) { 
                                    if (args.model.selectedItems.children.length > 0) { 
                                        return true; 
                                    } 
                                }, 
                                execute: function (args) { 
                                         var diagram = $("#diagram").ejDiagram("instance"); 
                   //remove the selected node/connector 
                  diagram.remove(diagram.model.selectedItems.children[0]); 
                                    // do your custom actions 
                                }, 
                                gesture: { 
                                    key: ej.datavisualization.Diagram.Keys.Delete, 
                                } 
                            } 
                        } 
                    }, 
                      
                }); 
            }); 
 
 
 
Regards, 
Shyam G 


Loader.
Up arrow icon