Categories | Question details Back To List | ||
How to prevent pasting when editing a cell and how to make keyboard copying work when grid loads I have been experiencing a few issues with copying and pasting using the keyboard and I have included the solutions below in case they should be of use to someone. The first problem I had was that when editing a cell if I tried to paste data using ctrl-v then the grid would close the cell editor (loosing any changes) and attempt to paste the data as a block selection. To prevent block pasting whilst the user is editing (and have any data pasted into the cell editor instead) add if (!mygrid.editor) { .... } around the copy/paste code. Secondly I was having a problem whereby I'd have to select a row on the grid before keyboard copy/pasting would work. To solve this you can call the mygrid.setActive(); method to make your grid the currently active dhtmlxgrid on the current page. mygrid.attachEvent("onKeyPress",onKeyPressed); mygrid.setActive(); function onKeyPressed(code,ctrl,shift){ if (!mygrid.editor) { if(code==67&&ctrl){ mygrid.setCSVDelimiter("\t") mygrid.copyBlockToClipboard() } if(code==86&&ctrl){ mygrid.pasteBlockFromClipboard() } } return true; } Answer posted on May 24, 2007 19:29 Both updates incorporated in main code branch and will be available as part of next version ( 1.4 ) Thanks for your code improvments. Answer posted by radyno (Support) on Dec 07, 2014 06:55 I hope this information will be enough for you. But you also can have a look at javascript horizontal slider and examples new topic. |