ExtJs關閉面板時清空面板中的內容

來源:互聯網
上載者:User

ExtJs關閉面板時清空面板中的內容

在用ExtJs寫前台代碼時,一些控制項在關閉時需要設定他的關閉為隱藏,方便下次繼續使用,但是如果使用者在填寫完資訊後直接關閉下次開啟後資訊繼續存在,影響使用者體驗。可以通過以下解決方案,設定關閉按鈕的監聽事件,當使用者點擊關閉按鈕後清空對應formpanel中的資料。

下面首先看一個formPanel,實現添加使用者介面。

var addUser = new Ext.form.FormPanel({labelAlign:'center',labelWidth:50,frame:true,defaultType : 'textfield',items: [{    fieldLabel:'使用者名稱',    name:'userName'    },{    fieldLabel:'使用者密碼',    name:'userPWD'    },{    fieldLabel:'使用者地區',    name:'userRegion'    }]});
然後看存放該formPanel的window。

var addUserswin = new Ext.Window({title: '添加使用者',    height: 200,    width: 400,    constrainHeader:true,    buttonAlign:'center',    closeAction:'hide',    items:[addUser],    buttons:[{    text:'新增',    handler:function(){    Ext.Msg.alert("ff","執行新增方法");    }    }]});
然後添加這個window的關閉按鈕監聽事件。

addUserswin.on('close',function(){addUser.getForm().reset();});
這就在關閉按鈕前清空formpanel中的內容。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.