View Full Version : grid panel keypress event
gurunath
5 Jul 2012, 2:29 AM
I am working on grid panel,
If user presses insert key a new record will insert
and if delete pressed selected row is deleted
but i am unable to find key pressed event and which key is pressed
Farish
5 Jul 2012, 2:39 AM
you can create a keymap:
var keyMap = Ext.create('Ext.util.KeyMap', Ext.getBody(), [
{
key: Ext.EventObject.DELETE,
shift: false,
ctrl: false,
fn: function() {
alert('Delete');
}
},
{
key: Ext.EventObject.INSERT,
shift: false,
ctrl: false,
fn: function() {
alert('Insert');
}
}
]);
Instead of Ext.getBody(), you should use the HTML element of your grid panel. You can set the shift and ctrl configs to true if you want the action to occur on Ctrl + Del or Shift + Del.
sword-it
5 Jul 2012, 3:09 AM
Hi gurunath,
You can use "itemkeydown" event of Ext.grid.View class. For example
Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
viewConfig:{
listeners:{
itemkeydown:function(view, record, item, index, e){
alert('The press key is' + e.getKey());
}
}
},
store: yourStore
columns: [
{
header: 'Name',
dataIndex: 'name'},
{
header: 'Email',
dataIndex: 'email',
flex: 1},
{
header: 'Phone',
dataIndex: 'phone'}
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});
For more information see http://docs.sencha.com/ext-js/4-1/#!/api/Ext.grid.View-event-itemkeydown
gurunath
5 Jul 2012, 6:33 AM
@Farish (http://www.sencha.com/forum/member.php?277826-Farish) Thanks man its working
:)~o)
Farish
5 Jul 2012, 6:42 AM
welcome. please mark the thread as answered so that it saves time for others.
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.