form表单使用样例

Ext.define('MyApp.view.MyForm', {
    extend: 'Ext.form.Panel',

    border: 0,
    height: 138,
    id: 'formPanel1',
    margin: 16,
    width: 167,
    layout: {
        type: 'auto'
    },
    bodyStyle: 'background-color:transparent;',

    initComponent: function() {
        var me = this;

        Ext.applyIf(me, {
            items: [
                {
                    xtype: 'textfield',
                    name: 'f_username',
                    fieldLabel: '用户名',
                    labelAlign: 'top'
                },
                {
                    xtype: 'textfield',
                    width: 150,
                    inputType: 'password',
                    name: 'f_password',
                    fieldLabel: '密码',
                    labelAlign: 'top'
                },
                {
                    xtype: 'button',
                    handler: function(button, event) {
                        var formPanel1 = Ext.getCmp('formPanel1');
                        var form1 = formPanel1.getForm();

                        formPanel1.setLoading(true);
                        form1.submit({
                            clientValidation: true,
                            url: 'Handler.ashx',
                            params: {
                                newStatus: 'delivered'
                            },
                            success: function(form, action) {
                                Ext.Msg.alert('成功', '操作完毕', function(){
                                    formPanel1.setLoading(false);
                                    parent.cs_close_defaultWin();   
                                });
                            },
                            failure: function(form, action) {
                                switch (action.failureType) {
                                    case Ext.form.action.Action.CLIENT_INVALID:
                                    Ext.Msg.alert('失败', 'Form fields may not be submitted with invalid values');
                                    break;
                                    case Ext.form.action.Action.CONNECT_FAILURE:
                                    Ext.Msg.alert('失败', 'Ajax communication failed');
                                    break;
                                    case Ext.form.action.Action.SERVER_INVALID:
                                    Ext.Msg.show({
             title:'失败',
             msg: action.result.msg,
             buttons: Ext.Msg.OK,
             icon: Ext.Msg.ERROR
            });
                                }
                                formPanel1.setLoading(false);
                            }
                        });

                    },
                    margin: '10 0 0 16',
                    width: 60,
                    text: '登录'
                }
            ]
        });

        me.callParent(arguments);
    }

});
--------------------------------------------------------------------------------------------------------------------------------
服务端代码:
context.Response.Write("{ success: true }");
context.Response.Write("{ success: false, msg: '密码不正确' }");
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

icewizardry

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值