在JQuery中,我可以使用class或tag选择器一次为input
多个元素设置一个值:
<form action="" id="mainForm">
<input type="text" name="Phone" class="deftext" value="" >
<input type="text" name="Number" class="deftext" value="" >
<input type="text" name="Name" class="deftext" value="" >
<input type="text" name="Lastname" class="deftext" value="" >
<input type="text" name="Middlename" class="deftext" value="" >
<input type="text" name="Age" class="deftext" value="" >
<input type="text" name="Email" class="deftext" value="" >
<input type="text" name="Occupation" class="deftext" value="" >
</form>
个字符
我可以在ExtJS 4中做同样的事情,将下面的代码修改为单行吗?
Ext.getCmp('mainForm').down('[name=Phone]').setValue('');
Ext.getCmp('mainForm').down('[name=Number]').setValue('');
Ext.getCmp('mainForm').down('[name=Name]').setValue('');
....
型
2条答案
按热度按时间lnxxn5zx1#
你的JQuery代码不是真正可读的,因为当你查看函数时,你看不到有多个字段受到影响。这就是为什么ExtJS不支持这样的语法。你可以使用
字符串
或者使用
型
与您的JQuery示例不同,这两个类都是可读的,因为我不必知道哪些类应用于哪些字段。
如果要将所有字段重置为上次
form.loadRecord
操作期间设置的值,或者如果未执行form.loadRecord
操作则重置为初始值,请使用form.reset
:型
ghhaqwfi2#
好吧,如果子组件有共同点(例如xtype),您可以这样做
字符串
但是不能,你不能在组件数组上使用组件方法。