• Home
  • About Me

Christoph M. Lütjen

Mein persönlicher Beitrag zur Netzvermüllung

Kategorie:

  • Diverses
  • Ext JS
  • JavaScript
  • webEdition WebCMS

Archiv:

  • April 2009
  • Februar 2009
  • Mai 2008
  • April 2008
  • Januar 2008
  • Dezember 2007

Blogroll:

  • living-e AG

Meta:

  • RSS
  • Kommentare als RSS
  • Gültiges XHTML
  • XFN

ExtJS: TextField in Toolbar mit Reaktion auf Return-Taste

April 12th, 2009 by chris

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 |

5 Responses

  1. Fralaylix Says:
    Juli 5th, 2009 at 12:10

    Hmm. Is it true? :-)

  2. buy_vigrxplus Says:
    Juli 15th, 2009 at 00:27

    Great post! I’ll subscribe right now wth my feedreader software!

  3. LnddMiles Says:
    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!

  4. kajolibyny Says:
    August 27th, 2009 at 06:20

    kajolibyny…

    Low Fades Haircuts …

  5. black hattitude Says:
    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.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

 
Wordpress Themes by and Website Templates by Blogcut