开发者

Reading a form-field in sencha touch extjs

开发者 https://www.devze.com 2023-04-02 16:19 出处:网络
I have a form field and i want to read the text entered into it, i tried the following code: this.searchButton = new Ext.Button({// The button press will invoke the search action

I have a form field and i want to read the text entered into it, i tried the following code:

this.searchButton = new Ext.Button({// The button press will invoke the search action
            text: 'Go',
            handler: this.searchButtonTap,
            scope: this
        });

this.topToolbar = new Ext.form.FormPanel({
                   items: [

                    {xtype: 'textfield',
                    name: 'search',
                    placeHolder: 'Search'},
                    this.searchButton

                ]
        });

 searchButtonTap: function () {
       // console.log(this.topToolbar.items.items[1]);
       var currentText = AsApp.views.AsListView.getRec开发者_如何学Pythonord();
        console.log(currentText);
    },


you may try this:

this.searchField = new Ext.form.Text({
            displayField: 'name',
            valueField: 'name',
            editable: true,
            forceSelection: true,
            triggerAction: 'all',
            emptyText: 'Search...',
            selectOnFocus: true
    });

this.searchButton = new Ext.Button({// The button press will invoke the search action
        text: 'Go',
        handler: this.searchButtonTap,
        scope: this
    });

    this.topToolbar = new Ext.Toolbar({
                   items: [
                { xtype: 'spacer' },    
                    this.searchField,
                    this.searchButton,
                    { xtype: 'spacer' },
                ]
        });



searchButtonTap: function () {
    var searchText = this.searchField.getValue();
    console.log(searchText);

    },


To get the value of a textfield, use the field's getValue() method.

For example:

var field = myTextField;
var currentText = field.getValue();

You can also use searchfield instead of textfield. It also has the getValue() method available.

0

精彩评论

暂无评论...
验证码 换一张
取 消