Ext.form.Panel表单加载

Ext.onReady(function ()
{
    //初始化提示
    Ext.QuickTips.init();
    var productForm = Ext.create("Ext.form.Panel", {
        title: "表单加载示例",
        width: 300,
        frame: true,
        fieldDefaults: {
            labelSeparator: ":",
            labelWidth: 80,
            width: 250,
            margin:5
        },
        renderTo: Ext.getBody(),
        items: [
            { fieldLabel: "产品名称", xtype: "textfield", name: "productName", value: "U盘" },
            { fieldLabel: "金额", xtype: "numberfield", name: "price", value: 100 },
            { fieldLabel: "生产日期", xtype: "datefield", format: "Y-m-d", name: "date", value: new Date() },
            { xtype: "hidden", name: "productId", value: "001" },
            { fieldLabel: "产品简介", name: "introduction", xtype: "textarea" }
        ],
        buttons: [
            { text: "加载简介", handler: loadIntroduction }
        ]
    });
    function loadIntroduction()
    {
        var params = productForm.getForm().getValues();
        productForm.getForm().load({
            params: params,
            url: "/AjaxHandler/productServer.ashx",
            method: "GET",
            waitMsg:"加载中,请稍后……",
            success: function (form, action)
            {
                //加载成功的处理
                Ext.MessageBox.alert("提示", "产品简介加载成功");
            },
            failure: function (form, action)
            {
                //加载失败的处理
                Ext.MessageBox.alert("提示", "产品简介加载失败<br/>原因是:" + action.result.errorMessage);
            }
        })
    }
})
productServer.ashx代码如下:
<pre name="code" class="csharp">public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/json";
            //context.Response.Write("Hello World");
            string productId = context.Request.Params["productId"];
            string result = string.Empty;
            if(productId=="001")
            {
                result = "{success:true,data:{introduction:'本产品美观实用,售后服务优秀。'}}";
            }
            else
            {
                result = "{success:false,errorMessage:'数据不存在'}";
            }
            context.Response.Write(result);
        }


 
<img src="https://img-blog.csdn.net/20150510171724095?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2h1eWl6aGk=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值