我有一个CloseAction=hide
窗口但是当我从代码隐藏中关闭它时
WndwAddSVar.Close();
并重新打开字段,其中包含先前的值。当我再次打开它时,如何将其清空?
这是窗口:
<ext:Window ID="WndwAddSVar" runat="server"
Width="650" Height="350" CloseAction="Hide"
X="120" Y="120" Hidden="true" Title="Add St Variables"
ConstrainHeader="true"
Layout="FitLayout">
<Items>
<ext:FormPanel runat="server">
<Items>
<ext:FieldSet runat="server" Margin="5" Collapsible="false">
<Items>
<ext:TextField runat="server" ID="txtSName" FieldLabel="SName" />
<ext:NumberField runat="server" ID="numBlactor" FieldLabel="Blactor" />
</Items>
</ext:FieldSet>
<ext:ButtonGroup runat="server">
<Buttons>
<ext:Button runat="server" Text="Save">
<DirectEvents>
<Click OnEvent="Save" />
</DirectEvents>
</ext:Button>
<ext:Button runat="server" Text="Cancel">
<Listeners>
<Click Handler="#{WndwAddSVar}.close()" />
</Listeners>
</ext:Button>
</Buttons>
</ext:ButtonGroup>
</Items>
</ext:FormPanel>
</Items>
</ext:Window>
答案 0 :(得分:0)
在ExtJs中,docs提供了重置表单组件内容的方法。您可以参考ExtJs docs
我已经创建了一个小型演示来向您展示它是如何工作的。 Sencha fiddle example
代码示例
var wind = Ext.create('Ext.window.Window', {
title: 'Testing',
closeAction:'hide',
layout: {
type: 'vbox',
align: 'center',
pack: 'center',
},
items: [{
xtype: 'form',
border:0,
bodyPadding:50,
defaults: {
xtype: 'textfield'
},
items: [{
fieldLabel: 'First Name'
}, {
fieldLabel: 'Last Name'
}, {
fieldLabel: 'Email'
}, {
fieldLabel: 'Phone Number'
}]
}],
listeners:{
hide:function(){
Ext.getCmp('openWind').show();
}
}
});
Ext.create('Ext.Button',{
renderTo: Ext.getBody(),
text:'Open Window',
id:'openWind',
handler:function(){
this.hide()
wind.show().down('form').getForm().reset()
}
})