ExtJs - FormPanel 未正确呈现
我有构造函数 (window + formPanel),
AddOrgWindowUI = Ext.extend(Ext.Window, {
title: 'Create something',
width: 400,
height: 200,
layout: 'fit',
initComponent: function() {
this.items = [
{
xtype: 'form',
id: 'add-form',
padding: 5,
initialConfig: Ext.apply(this.initialConfig, {
url: '123132.php'
}),
items: [
{
xtype: 'textfield',
fieldLabel: 'abbr',
anchor: '95%',
value: this.abbr,
emptyText: 'abbr'
}
],
buttons: [
{
text: 'Add',
handler: function() {
Ext.getCmp('add-form').getForm().submit();
}
}
]
}
];
AddOrgWindowUI.superclass.initComponent.call(this);
}});
但是当我尝试创建它时 - var AddOrgWindowForm = new AddOrgWindowUI({n_full:'aaa'});AddOrgWindowForm.show();
我得到一个空窗口 (没有表单面板)为什么 formPanel 无法正确渲染?我哪里有错误? 谢谢。
I have constuctor (window + formPanel)
AddOrgWindowUI = Ext.extend(Ext.Window, {
title: 'Create something',
width: 400,
height: 200,
layout: 'fit',
initComponent: function() {
this.items = [
{
xtype: 'form',
id: 'add-form',
padding: 5,
initialConfig: Ext.apply(this.initialConfig, {
url: '123132.php'
}),
items: [
{
xtype: 'textfield',
fieldLabel: 'abbr',
anchor: '95%',
value: this.abbr,
emptyText: 'abbr'
}
],
buttons: [
{
text: 'Add',
handler: function() {
Ext.getCmp('add-form').getForm().submit();
}
}
]
}
];
AddOrgWindowUI.superclass.initComponent.call(this);
}});
but when Im trying to create it - var AddOrgWindowForm = new AddOrgWindowUI({n_full:'aaa'});AddOrgWindowForm.show();
I get an empty window (without form panel) Why formPanel dont render properly? Where I have mistake?
Thx.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是当您将
initialConfig
分配给表单时,因为根据 ExtJS API 且不是有效的配置选项。因此,不必使用
initialConfig
来设置 url,您只需设置url
属性,因为表单也接受每个基本表单配置选项:或者如果您想让你的班级的用户使用默认网址之外的另一个网址:
顺便说一句,你的文本框没有
id
也没有name
,如果您正在提交此表单,因为这些表单将定义参数的名称,该参数将与文本框的值一起到达服务器。这里有固定的示例供您使用:http://jsfiddle.net/HPBvy/。您可以使用 firebug 或任何其他 Web 开发人员工具来查看 POST 调用。
The problem is when you assign the
initialConfig
to the form, as it is a readonly property according to ExtJS API and not a valid config-option.So instead of using
initialConfig
to set the url you just have to set theurl
property as every Basic Form config-option is accepted by the Form too:Or if you want to let the user of your class to use another url than the default one you could do:
And by the way, your textbox has no
id
norname
, and this is important if your are submitting this form, as these will define the name of the parameter that will arrive to the server with the value of the textbox.Here you have the fixed example for you to play with: http://jsfiddle.net/HPBvy/. You can use firebug or any other web-developer-tool to see the POST call.