1

フォーム フィールドがあり、そこに入力されたテキストを読みたいので、次のコードを試しました。

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.getRecord();
        console.log(currentText);
    },
4

2 に答える 2

1

あなたはこれを試すことができます:

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);

    },
于 2011-09-02T21:25:59.980 に答える
0

テキストフィールドの値を取得するには、フィールドの getValue() メソッドを使用します。

例えば:

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

searchfieldの代わりに使用することもできますtextfield。getValue() メソッドも使用できます。

于 2011-09-02T17:01:43.220 に答える