ExtJS 刷新

这是一种函数调用方式刷新
如:通过一个窗口的按钮刷新上一层的页面
1.

先通过定义获取上一层页面的this[insert是win窗口]
var me=this;

//插入数据
	doInsert : function(item, e, newGroup) {// 当前记录前插入一条记录
	       var me=this;
			 ......
            		..........

在win窗口定义的按钮handler: function 函数里添加me.refresh();

buttons: [
			{
			xtype: "button",
			text: "确定",
				handler: function () { 
					console.warn(form.getForm().getValues()) 
					 if(form.getForm().isValid()){
						 
						 var response=phis.script.rmi.miniJsonRequestSync({
								serviceId: "phis.TESTSTUDENTService",
								serviceAction : "insertTESTSTUDENT",
								body: form.getForm().getValues() 
							 } 
						 ); 
						 console.warn("已插入:"); 
						 win.close();
						me.refresh();
					console.warn(me);
					 }else{
						 console.log("输入内容不能为空"); 
					console.warn(me);
					me.refresh();
					
					 }
			    } 
			},

2
当前页面通过该页的某个按钮的函数实现刷新{刷新函数}this.loadData();
以下该方法是删除按钮,删除并执行刷新

doDelete : function() {// 当前记录前删除一条记录
		var selectdRecord = this.getSelectedRecord();//获取当前选择行数据
		//var selectRow = this.store.getCount();
		if(selectdRecord){
			var id = selectdRecord.get("ID")
			//console.warn(id);   
			var request = phis.script.rmi.miniJsonRequestSync({
				serviceId: "phis.TESTSTUDENTService",
				serviceAction: "removeTESTSTUDENT",
				body: {
					ID : id
				}
			}); 
			//刷新
		this.loadData();
		}

整个js代码:TESTSTUDENT.js

/**loadData:加载数据
 * doInsert :插入数据
 * doDelete : 当前记录前删除一条记录	
 * 
 */
$package("phis.application.cic.script");
$import("phis.script.SimpleList");
  
phis.application.cic.script.TESTSTUDENT = function (cfg) {
	cfg.data = [];
	this.serviceId = "phis." + this.serviceId;
	this.serviceAction = "TESTSTUDENT"; 
	phis.application.cic.script.TESTSTUDENT.superclass.constructor.apply(this, [cfg]);
}
 
	Ext.extend(phis.application.cic.script.TESTSTUDENT, phis.script.SimpleList, {
	loadData: function () {
		id="load";
		this.requestData.serviceId = "phis." + this.serviceId;
		this.requestData.serviceAction = "TESTSTUDENT"; 
		phis.application.cic.script.TESTSTUDENT.superclass.loadData.call(this);
	},
	
	//插入数据
	doInsert : function(item, e, newGroup) {// 当前记录前插入一条记录
	       var me=this;
			var form= new Ext.form.FormPanel({
			frame: true,   
			style: 'margin:6px',
			items: [
            		{  
            		xtype : "textfield",
                    fieldLabel : '姓名', 
					emptyText : '请输入姓名',
					name : "NAME",
					id : "NAME",
					width : 200
                    }, 
					{ 
                    xtype : "textfield",
					fieldLabel : "年龄",
					emptyText : '请输入年龄',
					maximizable:2,
					allowBlank : false, // 是否允许为空, 默认为 true
					blankText : "用户名不能为空", // 显示错误提示信息
					
					//name : "user.username", // name 属性应与 Struts2 Action 中的属性保持一致
					id : "AGE",
					width : 200  
                    },
					{
					fieldLabel: '性别',
					emptyText : '请选择性别',
					width : 200 ,
					name: 'SEX',
					xtype: 'combo',
					//本地数据源  local/remote
					mode:'local',
					//设置为选项的text的字段
					displayField: "Name",       
					//设置为选项的value的字段 
					valueField: "Id",
					//是否可以输入,还是只能选择下拉框中的选项
					editable : false, 
					typeAhead: true,
					//必须选择一项
					//forceSelection: true,
					//输入部分选项内容匹配的时候显示所有的选项
					triggerAction: 'all',
					//selectOnFocus:true,
					//数据
					store:new Ext.data.SimpleStore({
						fields: ['Id', 'Name'],
						data: [  [1,'男'],[0,'女'] ]
					})
            	 },{ 
                      xtype : "textfield",
                    fieldLabel : '住址',
					emptyText : '请输入地址',
					name : "ADRESS",
					width : 200
                    }, {  
                    fieldLabel : '年级',
					emptyText : '请选择年级',
					name : "GRADE",
					width : 200,
					xtype: 'combo',
					//本地数据源  local/remote
					mode:'local',
					//设置为选项的text的字段
					displayField: "Name",       
					//设置为选项的value的字段 
					valueField: "Id",
					//是否可以输入,还是只能选择下拉框中的选项
					editable : false, 
					typeAhead: true,
					//必须选择一项
					//forceSelection: true,
					//输入部分选项内容匹配的时候显示所有的选项
					triggerAction: 'all',
					//selectOnFocus:true,
					//数据
					store:new Ext.data.SimpleStore({
						fields: ['Id', 'Name'],
						data: [  [1,'大一'],[2,'大二'],[3,'大三'],[4,'大四'] ]
					})

					} 
			],
			listeners: {//双击事件
                "dblclick": { fn: this.doUpdate, scope: this}, 	
			}
		});
		var win = new Ext.Window({
			title: "插入数据",
			width: 360,
			height: 260,
			minimizable: true, // 最大化
			maximizable: true, // 最小化
			frame: true,
			constrain: true, // 防止窗口超出浏览器窗口,保证不会越过浏览器边界
			buttonAlign: "center", // 按钮显示的位置 
			plain: true, // 将窗口变为半透明状态。,
			items: form,
       	buttons: [
			{
			xtype: "button",
			text: "确定",
				handler: function () { 
					console.warn(form.getForm().getValues()) 
					 if(form.getForm().isValid()){
						 
						 var response=phis.script.rmi.miniJsonRequestSync({
								serviceId: "phis.TESTSTUDENTService",
								serviceAction : "insertTESTSTUDENT",
								body: form.getForm().getValues() 
							 } 
						 ); 
						 console.warn("已插入:"); 
						 win.close();
						me.refresh();
					console.warn(me);
					 }else{
						 console.log("输入内容不能为空"); 
					console.warn(me);
					me.refresh();
					
					 }
			    } 
			},
			{
			xtype: "button",
			text: "取消", 
				handler: function () { 
					console.warn("取消");
					win.close();
					me.refresh();
				} 
			}
    	]
		});
		win.show();
	console.warn(selectdRecord)
	}, 
	// doUpdate:function() {
		 //doUpdate自动获取执行系统共用方法
	// },

	doDelete : function() {// 当前记录前删除一条记录
		var selectdRecord = this.getSelectedRecord();//获取当前选择行数据
		//var selectRow = this.store.getCount();
		if(selectdRecord){
			var id = selectdRecord.get("ID")
			//console.warn(id);   
			var request = phis.script.rmi.miniJsonRequestSync({
				serviceId: "phis.TESTSTUDENTService",
				serviceAction: "removeTESTSTUDENT",
				body: {
					ID : id
				}
			}); 
			//刷新
		this.loadData();
		}
	 this.getStore().refresh();
	 console.warn("删除:") 
	}
	
})

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值