ExtJS: TextField in Toolbar mit Reaktion auf Return-Taste
Und noch ein kleines Beispiel. Diesmal die häufige Anforderung ein Suchfeld in einen Toolbar einzubauen, welches sich per Button oder natürlich per Enter/Return Taste absenden läßt.
tbar: [{
xtype: 'textfield',
id:'websearch-query',
width:300,
enableKeyEvents: true,
listeners: {
"keydown": function(field, event) {
if(event.getKey() == 13){
cmp.webSearch(field.getValue());
}
}
}
}, {
text:'Suchen',
handler: function(){ cmp.webSearch(Ext.getCmp('websearch-query').getValue()); },
scope: cmp
}]
“cmp” ist dabei eine zuvor gesetzte Referenz auf ein Objekt mit der Methode “webSearch”, hier muss natürlich individueller Code rein. Fallstrick ist eigentlich nur die Config-Option “enableKeyEvents”. Solange diese nicht gesetzt ist, wird das Textfeld nämlich keinerlei Key Events senden.
Posted in Diverses |
Juli 5th, 2009 at 12:10
Hmm. Is it true?
Juli 15th, 2009 at 00:27
Great post! I’ll subscribe right now wth my feedreader software!
Juli 22nd, 2009 at 04:58
Pretty cool post. I just stumbled upon your blog and wanted to say
that I have really liked reading your blog posts. Anyway
I’ll be subscribing to your blog and I hope you post again soon!
August 27th, 2009 at 06:20
kajolibyny…
Low Fades Haircuts …
Oktober 19th, 2009 at 08:12
Hi,
Thank you for the great quality of your blog, every time i come here, i’m amazed.
black hattitude.