EXTJS4 Text textfield

 
//工作太忙,没时间写这个,直接贴上来了
        Ext.require([
     'Ext.grid.*',
     'Ext.data.*'
 ]);
        var store;
        var PanTextBOx2;
       
        Ext.onReady(function ()
        {
            Ext.define('MyData', {
                extend: 'Ext.data.Model',
                fields: [
                     { name: "UserId", mapping: 'UserId' },  //第一个必须指定mapping,其他可以省略           
                     'UserName'
                ]
            });
            //创建数据源   
            store = Ext.create('Ext.data.Store', {
                model: 'MyData',
                buffered: true,
                proxy: {
                    //异步获取数据,这里的URL可以改为任何动态页面,只要返回JSON数据即可   
                    type: 'ajax',
                    url: 'DoQuery',
                    reader: {
                        type: 'json',
                        root: 'items'
                        //totalProperty  : 'total'   
                    }
                },
                autoLoad: true
            });
            //debugger
            //store.load();
            //定义查询按钮
//            Ext.create('Ext.Button', {
//                text: '查询',
//                width: 100,
//                renderTo: 'brnQuery',
//                iconCls: 'add',
//                iconAlign: 'left',
//                scale: 'medium',
//                listeners: {
//                    click: function ()
//                    {
//                        //this == the button, as we are in the local scope     
//                        // this.setText('I was clicked!');
//                        SetTxt();
//                        // return false;
//                    },
//                    mouseover: function ()
//                    {
//                        //set a new config which says we moused over, if not already set   
//                        //                        if (!this.mousedOver)
//                        //                        {
//                        //                            this.mousedOver = true;
//                        //                            alert('You moused over a button!\n\nI wont do this again.');
//                        //                        }
//                    }
//                }
//            });

            PanTextBOx2 = Ext.create('Ext.form.Panel', {
                title: 'Contact Info', width: 300, bodyPadding: 10, renderTo: Ext.getBody(),
                items: [
                { xtype: 'textfield',
                    itemId: 'Textbox3',
                    name: 'UserId',
                    fieldLabel: 'tetstsesdf',
                    value: 'sdddds',
                    // vtype:'int',
                    allowBlank: false
                    // requires a non-empty value    
                },
                      {
                          xtype: 'textfield',
                          itemId: 'Textbox4',
                          name: 'UserName',
                          fieldLabel: 'Email Address'//,
                          //vtype: 'email'
                          // requires value to be a valid email address format  
                      }]
            });

            var int = self.setInterval("SetTxt()", 3000)
            //setTimeout("SetTxt()", 3000);

        });

        var i = 1;
        function SetTxt()
        {
            store.load();
            //textBox1.value = i;
            if (store.getCount() > 0)
            {
                ModelTemp = store.getAt(0);  //取得第0条记录MODEL
              //  str = store.getAt(0).get('UserId');   //Model中的此字段数据
              //  str2 = store.getAt(0).get('UserName');
                PanTextBOx2.loadRecord(ModelTemp); //绑定数据
                //alert(str);
                //PanTextBOx2.items.items[0].focus();  
              //  var Textbox333 = PanTextBOx2.getComponent('Textbox3');  //取panel中的控件
              //  var Textbox444 = PanTextBOx2.getComponent('Textbox4');
              //  Textbox333.setValue(str);
              //  Textbox444.setValue(str2);
                 
            }
            i = i + 1;
        } 
  
   function loadModelData() { 

       // var gridPanel = this.getComponent('userGrid'), 
         //   formPanel = this.getComponent('userForm'), 
        //    newModel  = Ext.ModelManager.create({},  
         //                     'MyApp.models.UserModel'); 
         store.load();
        //gridPanel.getSelectionModel().clearSelections(); 
         PanTextBOx2.getForm().loadRecord(store.model) 
    }


 

    public class ButtonModel
    {
        public string UserId { get; set; }
        public string UserName { get; set; }
    }


 

      public ActionResult Button()
        {
            return View();
        }
        public ActionResult ButtonMRS()
        {
            return View();
        }
        [AcceptVerbs(HttpVerbs.Get)]
        public JsonResult GetMRSData()
        {
            List<ButtonModel> listModel = new List<ButtonModel>();

            listModel.Add(new ButtonModel() { UserId = i.ToString(), UserName = "test" + i.ToString() });
            i++;
            return Json(listModel, JsonRequestBehavior.AllowGet);
        } 

        static int i = 1;
        [AcceptVerbs(HttpVerbs.Get)]
        public JsonResult DoQuery()
        {
            List<ButtonModel> listModel = new List<ButtonModel>();

            listModel.Add(new ButtonModel() { UserId = i.ToString(), UserName = "test"+i.ToString() });
            i++;
            return Json(listModel, JsonRequestBehavior.AllowGet);
        } 
    }


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值