Skip to content

Slickgrid keydown issue when pasting from Excel

I am using Slickgrid and I want to be able to copy and paste from Excel.

The sample I have found allows this however, there is an issue I am experiencing (which can be seen in the example) and I think it is undesirable.

I have my cells editable, so basically, I single click into a cell and can type straightaway. I tab or cursor to another cell and again, I can type straight away.

With the example, I can’t do that anymore. I have to double click before I can enter anything.

The relevant plugin that handles paste from Excel is

I have found that if I comment line 63 on the above (_grid.focus()) then I get my single click and type, but then the paste doesn’t work.

Actually, let me correct that… I have just tried again with the _grid.focus() commented out and I can single click and type and I can paste from Excel. (Now, I am not sure why I even need the _grid.focus())

I don’t understand what the .focus() is doing so unfortunately, I am unable to fix it myself. It appears the .focus() is going off into the JQuery libraries, though why it should break the regular click and type, I don’t know.

Do I even need line 63 now? I am only (at the moment) ever going to paste into Slickgrid, not select from.

Any direction would be much appreciated.



[Edited] There are a couple of grid options that control the experience here.

If autoEdit is off, you need to double click the cell to get into edit mode (a single click just selects the cell). If it’s on, a single click will select and edit a cell.

If asyncEditorLoading is on, then the editors fire up immediately and, for example, in a text editor the text in the cell will start off fully selected (otherwise you require a second click to select the text).

Note however, with autoEdit on, you can’t select regions of the grid to cut and paste. This is an issue that will have to be dealt with in the grid code at some point (I am one of the project maintainers).

Here are the final options:

var options = {
  editable: true,
  enableAddRow: true,
  enableCellNavigation: true,
  asyncEditorLoading: true,
  autoEdit: true
10 People found this is helpful