开发者

sencha touch search form

开发者 https://www.devze.com 2023-03-15 07:11 出处:网络
I really hope someone can help me, It seems like this should be obvious but sencha documentation isn\'t very easy to read and incomplete. I am trying to build a search form but it doesnt seem to take

I really hope someone can help me, It seems like this should be obvious but sencha documentation isn't very easy to read and incomplete. I am trying to build a search form but it doesnt seem to take the store or the url and I can't figure out how to add parameters like page? Can anyone help? This code just produces Failed to load resource: null.

        var searchField = new Ext.form.Search({
            value:'Search',
            url: 'someur开发者_如何学Gol',
            store: this.data_store,
            cls:'searchfield',
            listeners: {
                focus: function(){ searchField.setValue(''); },
                blur: function(){ if( searchField.getValue()=='' ){ searchField.setValue('Search'); } },
                success: function(e){
                    console.log(e);
                }
            }
        });

   this.dockedItems = [ searchField ];


Ext.form.FormPanel doesn't take a Ext.data.Store or Ext.data.Model directly but does deal with Instances of Ext.data.Model. Lets say you have the following model:

Ext.regModel('MyForm', {
    fields: [{name: 'id', type: 'int'},'name','description']
    proxy: {
    type: 'ajax',
        url: 'url_to_load_and_save_form'
    }
})

Now your form definition would look something like this:

Ext.form.MyForm = Ext.extend(Ext.form.FormPanel, {
    record : null,
    model: 'MyForm',

    items: [{
        xtype: 'hidden',
        name: 'id' 
    },{
        xtype: 'textfield',
        name: 'name',
        allowBlank: false
    },{
        xtype: 'textarea',
        name: 'description'
    }],
    submit : function(){
        var record = this.getRecord() || Ext.ModelMgr.create({}, this.model);
        this.updateRecord(record , true);
        record.save({
            scope: this,
            success : function(record, opts){
                this.fireEvent('saved', record);
            },
            callback: function(){
                this.setLoading(false);
            }
        });
    }
});
Ext.reg('MyForm',Ext.form.MyForm);

Of course you should add in some validations and a button to actually call the Ext.form.MyForm.submit method.

0

精彩评论

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

关注公众号