當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
ExtJS 刷新
這是一種函數調用方式刷新
如:通過一個窗口的按鈕刷新上一層的頁面
1.
先通過定義獲取上一層頁面的this[insert是win窗口]
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();
以下該方法是刪除按鈕,刪除并執行刷新
整個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, // 是否允許為空, 默認為 trueblankText : "用戶名不能為空", // 顯示錯誤提示信息//name : "user.username", // name 屬性應與 Struts2 Action 中的屬性保持一致id : "AGE",width : 200 },{fieldLabel: '性別',emptyText : '請選擇性別',width : 200 ,name: 'SEX',xtype: 'combo',//本地數據源 local/remotemode:'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/remotemode:'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("刪除:") }})總結
- 上一篇: Extjs09 双击事件
- 下一篇: gradle idea java ssm