使用ExtJS4从textfield切换到displayfield [英] Switch from textfield to displayfield with ExtJS4

查看:314
本文介绍了使用ExtJS4从textfield切换到displayfield的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个在纯显示区域中显示值的表单。

I have created a form that displays values in plain displayfields.

表单旁边有一个编辑按钮,一旦用户点击,应该切换到正文字段,因此可以使数据可编辑。

There is an "edit" button next to the form and once clicked by the user, the displayfields should switch to being textfields and will, therefore, make the data editable.

我猜,这可以通过使用两个相同的表单来实现,一个可编辑,一个不可编辑并且基于用户点击了按钮,一个或另一个将是可见的。另一种方法也许是在点击按钮时动态选择xtype。

This, I am guessing, would be achieved by having two identical forms, one editable and one not and one or the other would be visible, based on the user having clicked the button. Another way, perhaps, is to have the xtype dynamically selected upon clicking the button.

有人可以指向某个方向来做到这一点吗?我是ExtJS的完整新手,只是开始学习ExtJS4。

Can anybody point me towards a certain direction in order to do this? I am a complete newbie to ExtJS and only just started learning ExtJS4.

提前谢谢。

M

推荐答案

首先将所有字段渲染为禁用的输入字段:true。然后将其用于编辑按钮处理程序:

Start by rendering all fields as input fields with disabled:true. Then use this for the Edit button handler:

 ...
 form.getForm().getFields().each(function(field) {
             field.setDisabled( false); //use this to enable/disable 
             // field.setVisible( true); use this to show/hide
 }, form );//to use form in scope if needed

这篇关于使用ExtJS4从textfield切换到displayfield的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆