Jump to content

DBGrid keyboard navigation ...


NDzubiel

Recommended Posts

Well,

I would like to use the keyboard to navigate in the grid - something like this here:

https://fiddle.sencha.com/#fiddle/ron&view/editor

Can this be done without changing the source code ?

If not - I found the place where to modify the DBGrid - I just need to
find the please to inject the following code into the "Ext.application({" 

Can you give me a tipp on how to do this ?

 

Thanks

 

Nils

 

----- functions I would like to inject ----

 

function getDirection(e) {
            if (e.getKey() == e.LEFT) return 'left'
            else if (e.getKey() == e.RIGHT) return 'right'
            else if (e.getKey() == e.UP) return 'up'
            else if (e.getKey() == e.DOWN || e.getKey() == e.ENTER) return 'down'
        }

        function specialKeyFunction(field, e) {
            console.log(field);
            var grid = field.up('grid')
            var pos, newPos, cellMod;
            cellMod = grid.selModel;
            pos = grid.selModel.getCurrentPosition();

            var dir = getDirection(e);

            if (pos) {
                newPos = pos.view.walkCells(pos, dir, e, cellMod.preventWrap);
                if (newPos) {
                    newPos.view = pos.view;
                    cellMod.setCurrentPosition(newPos);
                }
            }
            
            Ext.defer(function() {
                grid.editingPlugin.startEdit(newPos.row, newPos.column);
            }, 100)
        };

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...