从控制器设置窗口字段值
Setting window field values from controller
我有一个窗口,当单击某个单元格时,它会在弹出窗口中显示有关用户的值.. 在我的用户控制器中,我根据 id 加载了用户的 json,有没有办法将此 json 的特定值传递到我的窗口中?我知道我可以使用 .getForm().setValues() 如果它是一个表单。我可以在窗口中嵌套表单吗?
控制器代码段:
loadUserDetails: function(userId) {
var view = Ext.widget('userdetails').show();
Ext.Ajax.request({
url: /user/get.htm?alt=json',
params: { id: userId },
success: function(response) {
var json = Ext.JSON.decode(response.responseText);
}
});
}
视图代码段(窗口):
Ext.define('App.view.user.UserDetails', {
extend: 'Ext.window.Window'
,alias: 'widget.userdetails'
,id: 'userdetails'
,title: 'User Details'
,height: 300
,width: 380
,initComponent: function() {
var me = this;
this.items = [{
xtype: 'fieldset',
title: 'Information',
margin: '5',
width: 350,
height: 250,
defaults: {xtype: 'displayfield', margin: '3', labelWidth: 100, width: 300},
items: [{
id: 'id',
width: 150,
fieldLabel: 'User Id'
},{
id: 'email',
width: 250,
fieldLabel: 'User Email'
}]
}];
this.callParent(arguments);
}
});
给定这个类:
Ext.define('App.view.user.UserDetails', {
extend: 'Ext.window.Window'
,alias: 'widget.userdetails'
,id: 'userdetails'
,title: 'User Details'
,height: 300
,width: 380
,items: [{
xtype: 'fieldset',
title: 'Information',
margin: '5',
width: 350,
height: 250,
defaults: {xtype: 'displayfield', margin: '3', labelWidth: 100, width: 300},
items: [{
// you should avoid using fixed id that will prevent using the component
// multiple times
// id: 'id',
width: 150,
fieldLabel: 'User Id'
,itemId: 'userId' // <= add item id for easy retrieval
},{
// id: 'email',
width: 250,
fieldLabel: 'User Email'
,name: 'userEmail' // <= or a name, as is logical for a field
}]
}]
});
您可以使用组件查询来获取对字段的引用并设置其值:
var win = Ext.create('App.view.user.UserDetails', {
autoShow: true
});
// query by itemId
win.down('#userId').setValue(123);
// or by name
win.down('field[name=userEmail]').setValue('user@example.com');
或者,您可以在窗口中嵌套表单,以便可以使用setValues
(和其他表单功能):
Ext.define('App.view.user.UserDetails', {
extend: 'Ext.window.Window'
,alias: 'widget.userdetails'
,id: 'userdetails'
,title: 'User Details'
,height: 300
,width: 380
,layout: 'fit'
,items: [{
xtype: 'form'
,items: [{
xtype: 'fieldset',
title: 'Information',
margin: '5',
width: 350,
height: 250,
defaults: {xtype: 'displayfield', margin: '3', labelWidth: 100, width: 300},
items: [{
width: 150,
fieldLabel: 'User Id'
// name is required for setValues to work
,name: 'userId'
},{
// id: 'email',
width: 250,
fieldLabel: 'User Email'
,name: 'userEmail'
}]
}]
}]
});
var win = Ext.create('App.view.user.UserDetails', {
autoShow: true
});
win.down('form').setValues({
...
});
相关文章:
- 将Overlay添加到弹出窗口并添加输入类型字段以退出表单
- 无法根据用户在编辑窗口中的输入显示/隐藏jtable jquery字段
- 用于编辑输入字段的弹出窗口
- 是否可以在Kendo网格中只显示来自Kendo数据源的某些字段,而在“;添加“;弹出窗口
- 用于从剪贴板中的表自动填充活动浏览器窗口中的字段的脚本
- 当用户输入时打开一个弹出窗口,使用javascript填充表中的输入字段
- 在选择(rails_admin)时更改时在模态窗口中添加新字段
- Javascript open.window 获取字段值,然后将值插入父窗口
- 如何使用 javascript 在新窗口中的 html 字段中显示值
- 模态窗口(弹出窗口)警报在使用 angularJs 的错误字段上显示
- 将鼠标悬停在表行上时,如何显示包含该行字段数据的弹出窗口
- mailto:新窗口,但“收件人”字段地址 mailto:user@test.com
- 在媒体窗口中选择图片后添加/更新自定义字段(WordPress)
- 如何在 dialog() 模式弹出窗口中的部分视图之间保留字段数据
- 单击输入字段触发器窗口大小调整
- CKEditor:在插件“图像”的对话框窗口中设置输入字段的值
- 从控制器设置窗口字段值
- PHP-如何从列表视图在另一个浏览器窗口中显示详细记录字段
- jquery.ptTimeSelect.js如何显示输入字段上方的弹出窗口
- 使用javascript/jquery将多个输入字段中的值传递到弹出窗口