Is there a way to deselect Grid item when user clicks outside Grid in application?
I am adding context menu and keyboard shortcuts. They work in the Grid, but now I will need to add them for a tree also. When I click on the tree, and press ctrl-V, it still pastes clipboard into the Grid. But it must deselect, and paste nothing, if he clicked outside the Grid.
Thanks!
var contextmenu = new dhtmlXMenuObject("contextMenu", "menu_default");
contextmenu.renderAsContextMenu();
contextmenu.loadXML("ContextMenu.xml")
contextmenu.attachEvent("onClick", function(id, zoneId, casState){
if ( id == "cut" ) {
acgrid.setCSVDelimiter('\t');
acgrid.rowToClipboard();
acgrid.deleteSelectedRows();
} else if ( id == "copy") {
acgrid.setCSVDelimiter('\t');
acgrid.rowToClipboard();
} else if ( id == "paste") {
acgrid.addRowFromClipboard();
} else if ( id == "delete") {
acgrid.deleteSelectedRows();
} else if ( id == "find") {
alert(" find was clicked " + acgridcopyloc);
}
});
var acgrid = dhxLayout.cells("c").attachGrid();
acgrid.setImagePath("codebase/imgs/");
acgrid.setSkin("light");
acgrid.enableUndoRedo();
acgrid.enableDragAndDrop(true, true);
acgrid.enableMultiselect(true);
acgrid.enableContextMenu(contextmenu);
acgrid.attachEvent("onKeyPress",onKeyPressed);
function onKeyPressed(code,ctrl,shift){
var acgridloc = acgrid.getSelectedId();
if ( acgridloc != null ) {
if(code==46){
acgrid.deleteSelectedRows();
}
if(code==67&&ctrl){
acgrid.setCSVDelimiter('\t');
acgrid.rowToClipboard();
}
if(code==86&&ctrl){
acgrid.addRowFromClipboard();
}
if(code==88&&ctrl){
acgrid.setCSVDelimiter('\t');
acgrid.rowToClipboard();
acgrid.deleteSelectedRows();
}
if(code==90&&ctrl){
alert(" ctrlz ");
acgrid.doUndo();
}
return true;
}
}
acgrid.loadXML("SampleGrid.xml");