Extjs:访问链接在窗口中的属性网格
Extjs: Accessing Proprety Grid linked in a window
我需要访问创建的NewPerson窗口的PropertyGrid。
- NewPerson窗口由一个属性网格和一个工具栏组成
- 当用户填写属性网格并点击"保存"按钮时应该使用房地产网
- 问题是,用户应该能够根据需要创建任意多的NewPerson窗口,那么我如何访问窗口的属性网格呢?谢谢
新人窗口视图:
Ext.define('MyApp.view.ui.NewPerson', {
extend: 'Ext.window.Window',
height: 180,
width: 524,
resizable: false
,
layout: {
type: 'fit'
},
title: 'New Person',
initComponent: function() {
var me = this;
Ext.applyIf(me, {
dockedItems: [
{
xtype: 'newpersontoolbar',
dock: 'bottom'
}
],
items: [
{
xtype: 'newpersongrid'
}
]
});
me.callParent(arguments);
}
});
NewPersonGrid视图:
Ext.define('MyApp.view.ui.NewPersonGrid', {
extend: 'Ext.grid.property.Grid',
border: 0,
id: 'newpersongrid',
forceFit: true,
initComponent: function() {
var me = this;
Ext.applyIf(me, {
source: {
'Property 1': 'String',
'Property 2': true,
'Property 3': '2012-02-20T19:22:06',
'Property 4': 123
},
listeners: {
afterlayout: {
fn: me.onPropertyAfterLayout,
scope: me
}
}
});
me.callParent(arguments);
},
onPropertyAfterLayout: function(abstractcontainer, layout, options) {
}
});
NewPersonToolbar视图:
Ext.define('MyApp.view.ui.NewPersonToolbar', {
extend: 'Ext.toolbar.Toolbar',
initComponent: function() {
var me = this;
Ext.applyIf(me, {
items: [
{
xtype: 'savebutton'
}
]
});
me.callParent(arguments);
}
});
保存按钮视图:
Ext.define('MyApp.view.ui.SaveButton', {
extend: 'Ext.button.Button',
text: 'Save person',
initComponent: function() {
var me = this;
Ext.applyIf(me, {
listeners: {
click: {
fn: me.onButtonClick,
scope: me
}
}
});
me.callParent(arguments);
},
onButtonClick: function(button, e, options) {
// GRID = code here to access propertygrid
Ext.create('MyApp.model.Person', Ext.encode(GRID.getSource()));
}
});
由于MyApp.view.ui.NewPerson
是一个同时包含属性网格和保存按钮的组件,因此将两者绑定在一起的逻辑是有意义的:
Ext.define('MyApp.view.ui.NewPerson', {
extend: 'Ext.window.Window',
...
initComponent: function() {
var me = this;
Ext.applyIf(me, {
dockedItems: [
{
xtype: 'newpersontoolbar',
dock: 'bottom'
}
],
items: [
{
xtype: 'newpersongrid'
}
]
});
me.callParent(arguments);
me.down('#savePersonButton').handler = function(button, e) {
me.down('#newpersongrid').doSomething();
}
}
});
您需要将itemId = 'savePersonButton'
和itemId = 'newpersongrid'
属性分别添加到按钮和网格中(因为它不是id
,所以可以在组件的许多实例中使用,但每次都将被限定为一个容器。
相关文章:
- 使用导航属性创建Kendo UI网格模型的问题
- Extjs 3.4 中属性网格行值的工具提示 /Qtip(鼠标悬停)
- Ext.js将列添加到属性网格中
- 在剑道网格中,我可以用一个函数动态设置列属性吗
- 将列表的css列计数属性相应地绑定到引导网格类
- 无法设置属性'网格'的未定义
- 剑道网格分组列 - 类型错误:无法读取未定义的属性“长度”
- 在网格视图中获取属性“行”时出错
- 将属性添加到复选框后退网格
- 检索网格视图中复选框的选中属性
- 剑道网格 - 单击“添加新行”按钮后,获取剑道网格未捕获的类型错误:无法读取“名称”空的属性
- 访问网格数据存储的加载函数内的sortInfo属性
- 使用多种材质渲染网格时无法读取 undef 的属性“均匀”
- 从实体主页(网格视图)检索实体属性
- Kendo UI网格-单元格上的标题属性
- "无法读取属性'选项'未定义的“;尝试更新数据网格时的EasyUI
- Kendo序列化的Javascript数组网格对象属性在服务器上为null
- Extjs:访问链接在窗口中的属性网格
- 设置属性网格's标头可见
- ExtJS操作属性网格源信息