我是ExtJS的新手。我开始编写一个小表格。而且我对使用Ext.create和新运算符完全感到困惑。ExtJS中的对象。 Ext.create或新运营商?
所以这里是代码:
我想编写一个表单。我在其中一个sencha页面上找到了一个小例子。它创建这样一种形式:
var descAndSystem = new Ext.form.Panel ({
region: 'center',
layout: 'vbox',
margins: '5 5 5 5',
xtype: 'form',
title: 'Some title',
id: 'descAndSystem',
width: '800',
items: [
{ xtype: 'textarea',
fieldLabel: 'Provide a description',
name: 'rightdescription',
},
{
xtype: 'combobox',
fieldLabel: 'Choose System',
store: systems,
queryMode: 'local',
displayField: 'name',
valueField: 'name',
name: 'system'
}
]
});
然后我用descAndSystem作为组分在视口中:
Ext.create('Ext.container.Viewport', {
layout: 'border',
id: 'wizardcontainer',
items: [
descAndSystem,
{
region: 'south',
layout: 'hbox',
margins: '5 5 5 5',
items: [
{ xtype: 'button', text: '<< Back', handler: onNext },
{ xtype: 'button', text: 'Next >>', handler: onNext },
{ xtype: 'button', text: 'Cancel', align: 'right', handler: function() { alert ('Abgebrochen geklickt.'); } }
]
}
]
});
大量的试验和错误,我发现我可以访问我的表单值后下面的代码:
Ext.getCmp ('descAndSystem').getForm().findField ('rightdescription').getValue()
对比什么的,我买了一本书说,下面的代码没有工作:
Ext.getCmp ('rightdescription').getValue()
但我真正的问题是,我期望
Ext.create ('Ext.form.Panel', { .... });
相同
new Ext.form.Panel ({...});
但是当我做了后者的Chrome解释说:
Uncaught TypeError: Cannot read property 'Panel' of undefined'
再次,经过大量的反复试验,以下工作:
new Ext.Panel ({...});
不仅如此,我找不到文档中该名称的对象的任何引用,还行
Ext.getCmp ('descAndSystem').getForm().findField ('rightdescription').getValue()
现在产生一个错误:
Uncaught TypeError: Object [object Object] has no method 'getForm'
另外,我试图用DOM操作替换另一种形式的descAndSystem,文档中有各种替换方法。他们都没有工作,我总是得到错误消息“没有办法”取代“”。 我有强烈的怀疑,我从根本上弄错了什么。任何提示?我在Ubuntu 10.10 64位上使用ExtJS 4和Chromium 17.0.963.56。
你一定在做错事。 Ext.create('className',{})会产生与新的className({})相同的结果。 – pllee 2012-02-29 03:26:27