SlickGrid icon indicating copy to clipboard operation
SlickGrid copied to clipboard

enter key goes to next cell but not in edit mode

Open philcruz opened this issue 11 years ago • 7 comments

I have my grid set up so that if you edit a cell, when you hit enter, you go to the next row and can type in the cell and repeat. This way you can easily enter data from the keyboard. This is how spreadsheets typically work.

http://screencast.com/t/r4hDQeJNrZI1

when I register the plug in, i.e.

grid.registerPlugin(new Slick.CellExternalCopyManager(pluginOptions));

The grid no longer works that way. It goes to the next row but it's not in edit mode. So then you have to double-click and you can't easily enter a bunch of data

http://screencast.com/t/uRYvwSl886a

Any idea how to get around that?

Thanks, Phil

philcruz avatar Oct 07 '13 20:10 philcruz

Could you provide the code on http://jsfiddle.net/ ?

Celebio avatar Oct 08 '13 08:10 Celebio

Here you go

http://jsfiddle.net/philcruz/4UyNA/11/

The way it's set up the line to register the plugin is commented out so the behavior when you hit enter is as desired (moves to the next row, with the cursor in the field so you can enter data). If you uncomment that line and register the plugin, it doesn't work.

philcruz avatar Oct 08 '13 16:10 philcruz

Are you able to see the issue? I'm not familiar with how the plugin works, but if you can point me in the right direction I'll try to fix it. Thanks.

philcruz avatar Oct 17 '13 21:10 philcruz

Hi Phil, I will try to have a look on it next week as it's something annoying for me as well. If I don't have time for this in the near future I will let you know. Onur

Celebio avatar Oct 18 '13 06:10 Celebio

Hi, I still didn't manage to find time to work on this, unfortunately I have higher prioritized tasks to do. It's an important issue though, hopefully someone (may be me?) will have a look on this.

Celebio avatar Oct 28 '13 10:10 Celebio

on line 50 (cellexternalcopymanager.js):
cellSelectionModel.onSelectedRangesChanged.subscribe(function(e, args){ _grid.focus(); }); disables the autoEdit or forceEdit mode. However if you don't have this - selecting ranges become problematic. I have the same issue as philcruz and chose slickgrid because it can behave like google docs or excel. I am going to take a crack at it to see if there is a design to enable autoedit and copy range at the same time. will share if something works out. Cheers.

kaustuv avatar Oct 30 '13 04:10 kaustuv

Hacked something up - seems to work. http://jsfiddle.net/hXECL/3/ Set 'autoEdit' to false and add a handler to the keydown and click event.

    var makeActiveCellEditableSwitch = true;

    grid.onKeyDown.subscribe(function(e, handler) {
        if (e.ctrlKey || e.metaKey || e.shiftKey) { // with modifier keys
            if(e.which == 90 && (e.ctrlKey || e.metaKey)) { // CTRL + (shift) + z
                if (e.shiftKey) {
                    undoRedoBuffer.redo();
                } else {
                    undoRedoBuffer.undo();
                }
            }
        } else {                                                   // no modifier keys
            if (e.which == 37) {
                makeActiveCellEditableSwitch = true;
            } else if (e.which == 39) {
                makeActiveCellEditableSwitch = true;
            } else if (e.which == 38) {
                makeActiveCellEditableSwitch = true;
            } else if (e.which == 40) {
                makeActiveCellEditableSwitch = true;
            } else if (e.which == 9) {
                makeActiveCellEditableSwitch = true;
            } else if (e.which == 13) {
                grid.navigateDown();
                makeActiveCellEditableSwitch = true;
            } else {
                if (makeActiveCellEditableSwitch) {
                    grid.editActiveCell();
                    makeActiveCellEditableSwitch = false;
                }
            }
        }
    });

    grid.onClick.subscribe(function(e, handler) {
        makeActiveCellEditableSwitch = true;
    });

Just playing with Slickgrid for a couple days - if there is a less hacky solution would love to know! Cheers.

kaustuv avatar Oct 30 '13 06:10 kaustuv