PDA

View Full Version : Grid with itemkeydown event bind to the grid.view



telemmaite
16 Mar 2012, 12:51 PM
Hi to every one i have one quick question that does not require posting any code or maximum 2 lines.
I have a simple grid ( any grid from the examples will do) I bind an itemkeydown event to the grid.view by using

viewConfig: {
listeners:{
itemkeydown:function(){
console.log('adasdasd');
}
},.
}



This works nicely BUT only if a row of the grid is selected at least once! Then i can deselect the row and the event still works...but unless i select a row (focusing a row is not working ) I cannot get it to work :(
Any ideas how to make it work I tried focusing the grid.getView().el with focus() the only way i see it working is by quickly selecting deselecting a row of the grid at rendering to get it working...but shouldn`t it work right out of the box ?

mitchellsimoens
16 Mar 2012, 12:57 PM
It says it will only fire when:


Fires when a key is pressed while an item is currently selected.

telemmaite
16 Mar 2012, 1:11 PM
Im very sorry that i did not make it clear. I tested every event i could think of like :containerkeydown (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.view.View-event-containerkeydown), keydown, (the only one i mentioned actually ) itemkeydown ... All of them work but i have to click somewhere on the grid first it is actually not needed to select a row i could remove/hide one column click on the white space there and dang every thing starts working BUT unless i do that no events are caught :(


viewConfig: {
listeners:{
itemkeydown:function(){
console.log('itemkeydown');
},
containerkeydown:function(){
console.log('container');
},
},

}

});
grid.el.on('keydown',function(){
console.log('IT WORKS A')
})
grid.getView().el.on('keydown',function(){
console.log('IT WORKS B')
})


Then if i click on the white space out of the grid all of the events are gone again... how can i focus a grid to start working at afterrender so i don`t have to select a row or click somewhere on the white-space inside the grid to register the events