Results 1 to 5 of 5

Thread: Access to textfield value in tbar

  1. #1

    Default Access to textfield value in tbar

    Hi,
    I have a textfield and a button in a tbar, when I write a text in textfiled and press the buttom start the load of a datastore for a grid.

    Definition of the textfield
    Code:
        var searchField = {
                xtype: 'textfield',
                displayField: 'name',
                valueField: 'name',
                editable: true,
                forceSelection: true,
                triggerAction: 'all',
                emptyText: 'Search...',
                selectOnFocus: true,
    Definition of the tbar:

    Code:
    searchField,
    {xtype: 'tbbutton', text: 'Search', icon: 'images/bomb.png', handler: function(){ 
                     Store.load({params: { 'search': searchField.getvalue() }});  
                                                                                          }},
    All work correcrtly, I see the tbar, I see the test field and the button, alsto the ajax request work for load datastore but I not able to read the value of the text field by the function in button handler. (IN RED) then when I load the datastore the params SEARCH is always empity.

    Thanks in advance

    Steve

    How I can do it ?

  2. #2
    Sencha User ashaihullin's Avatar
    Join Date
    Jan 2010
    Location
    Kyrgyzstan, Bishkek
    Posts
    67

    Default

    i think you need to use scope or get your field by ID

  3. #3

    Default

    Thanks for your reply,

    use scope how ? can you post me an example ?

  4. #4
    Sencha User ashaihullin's Avatar
    Join Date
    Jan 2010
    Location
    Kyrgyzstan, Bishkek
    Posts
    67

    Default

    Something like this:
    Code:
    Ext.onReady(function(){
    
        searchField = new Ext.form.TextField({
                displayField: 'name',
                valueField: 'name',
                editable: true,
                forceSelection: true,
                triggerAction: 'all',
                emptyText: 'Search...',
                selectOnFocus: true
        });
    
        var but = new Ext.Button({
    	    text: 'Search', 
    	    scope: this, 
    	    handler: function(){ 
                     console.log(this.searchField.getValue()); 
    	    }
        });
    
        var pan = new Ext.Panel({
    	items: [but],
    	bbar: [ searchField ]
    
        });
    
        pan.render( document.body );
    });
    just play with it...

  5. #5

    Default

    WORK! Thanks a lot
    Steve

Similar Threads

  1. Replies: 4
    Last Post: 24 Mar 2010, 6:10 AM
  2. tbar - textfield dynamic length
    By heidtmare in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 15 Jun 2009, 1:35 PM
  3. Getting access to a grid from tbar button
    By ritcoder in forum Ext 2.x: Help & Discussion
    Replies: 8
    Last Post: 4 Oct 2008, 12:53 PM
  4. Can't access variable class Textfield value
    By neo4200 in forum Ext 2.x: Help & Discussion
    Replies: 26
    Last Post: 19 Sep 2008, 11:39 AM
  5. tabs tbar dissapears when tbar button clicked
    By robert_speer in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 11 Aug 2008, 7:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •