0

私はextjs 4.0コントローラを持っています:

Ext.define('KS.controller.DailyReport', {
extend: 'Ext.app.Controller',

views: ['report.Daily'],


init: function() {
    this.control({
        'dailyReport button[action=send]': {
            click: this.sendDailyReport
        }
    });
},

sendDailyReport: function(button) {
    var win = button.up('window');

    form = win.down('form');
    form.getForm().waitMsgTarget = form.getEl();
    form.getForm().waitMsg = 'Sending...';
    if (form.getForm().isValid()) { // make sure the form contains valid data before submitting
        form.submit({
            success: function(form, action) {
                Ext.Msg.alert('Success', action.result.msg);
            },
            failure: function(form, action) {
                Ext.Msg.alert('Failed', action.result.msg);
            }
        });
    } else { // display error alert if the data is invalid
        Ext.Msg.alert('Invalid Data', 'Correct them!')
    }
}
});

および extjs ビュー:

Ext.define('KS.view.report.Daily', {
extend: 'Ext.window.Window',
alias: 'widget.dailyReport',

title: 'Daily report',
layout: 'fit',
autoShow: true,
initComponent: function() {
    this.items = [{
        waitMsgTarget: true,
        xtype: 'form',
        url: 'dailyReport.php',
        layout: 'fit',
        waitMsgTarget: true,
        waitMsg: 'Sending...',
        items: [{
            margin: 10,
            xtype: 'datefield',
            name: 'reportDate',
            fieldLabel: 'Report for:',
            format: 'd.m.Y.',
            altFormats: 'd.m.Y|d,m,Y|m/d/Y',
            value: '12.12.2011',
            disabledDays: [0]
        }]
    }];

    this.buttons = [{
        text: 'Send',
        action: 'send'
    },
    {
        text: 'Cancel',
        scope: this,
        handler: this.close
    }];

    this.callParent(arguments);
}
});

ご覧のとおり、waitMsgTarget と waitMsg を両方の場所に設定しようとしましたが、[送信] ボタンをクリックしても表示されません。

なにが問題ですか?

4

1 に答える 1

2

あなたは本当にwaitMsg次のように誤用しています。

  1. waitMsgExt.form.BasicORの構成オプションではありませんExt.form.Panel。はwaitMsg内で設定する必要がありますExt.form.action.Submit。これが、ビューでの設定が機能しない理由です。
  2. コントローラーで同じことを行い、waitMsgを のプロパティであるかのように設定しますExt.form.Basic

修正は簡単です。に設定waitMsgしますExt.form.action.Submit。したがって、行form.submit()を次のように変更するだけです。

form.submit({
    waitMsg: 'Sending...',
    success: function(form, action) {
            Ext.Msg.alert('Success', action.result.msg);
        },
    //..... your other stuff here
});

コントローラーから次の行を削除します。

form.getForm().waitMsgTarget = form.getEl();
form.getForm().waitMsg = 'Sending...';

完全を期すために、これらの2行をビューから削除します(waitMsgTargetそこに2回あります):

waitMsgTarget: true,
waitMsg: 'Sending...',

waitMsgTarget: をフォーム自体以外のものに定義するには、ターゲットのIDを渡す必要があります。

たとえば、ビュー (フォーム定義) を次のように変更waitMsgTarget: trueします。

waitMsgTarget: 'myWindowID', 
//where myWindowID is the id of the container you want to mask

参考までに、http: //docs.sencha.com/ext-js/4-0/#!/api/Ext.form.action.Submitおよび http://docs.sencha.com/ext-js/を参照してください。 4-0/#!/api/Ext.form.Basic

于 2011-09-23T13:47:18.077 に答える