Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 创建简单的ExtJS表单_Javascript_Forms_Extjs - Fatal编程技术网

Javascript 创建简单的ExtJS表单

Javascript 创建简单的ExtJS表单,javascript,forms,extjs,Javascript,Forms,Extjs,我正试图用ExtJS2.3.0创建一个非常简单的模态表单。我使用的代码是: <html> <head> <link rel="stylesheet" href="ext-all.css"/> <link rel="stylesheet" href="dash.css" /> <script type="text/javascript" src="ext-base.js"></script> <script type=

我正试图用ExtJS2.3.0创建一个非常简单的模态表单。我使用的代码是:

<html>
<head>
<link rel="stylesheet" href="ext-all.css"/>
<link rel="stylesheet" href="dash.css" />

<script type="text/javascript" src="ext-base.js"></script>
<script type="text/javascript" src="ext-all-debug-TPF-212.js"></script>

<script type="text/javascript">
Ext.onReady(function () {

    var entitySearchForm = new Ext.form.FormPanel({
        title: "Basic Form",
        width: 425,
        frame: true,
        items: [
        new Ext.form.TextField({
            hideLabel: true,
            width: 275,
            allowBlank: false
        })],
        buttons: [{
            text: "Save"
        }]
    });

    var entitySearchWindow = new Ext.Window({
        layout: 'anchor',
        closable: true,
        resizable: false,
        draggable: false,
        modal: true,
        items: [entitySearchForm]
    });

    entitySearchWindow.show();
});
</script>

</head>
<body></body>
</html>

Ext.onReady(函数(){
var entitySearchForm=new Ext.form.FormPanel({
标题:“基本形式”,
宽度:425,
框架:对,
项目:[
新建Ext.form.TextField({
希德拉贝尔:没错,
宽度:275,
allowBlank:false
})],
按钮:[{
文本:“保存”
}]
});
var entitySearchWindow=新的外部窗口({
布局:“锚定”,
closable:是的,
可调整大小:false,
可拖动:错误,
莫代尔:是的,
项目:[entitySearchForm]
});
entitySearchWindow.show();
});
这将导致出现以下表单:

这有几个问题:

  • “保存”按钮看起来不像按钮(尽管它的行为确实像按钮)。我希望保存按钮看起来像一个按钮,宽度约为100px,并显示在文本框的右侧(而不是下方)
  • 有两条窄的短条纹,一条在文本字段的两侧。我怎样才能摆脱这些
  • 表单没有关闭按钮,即使我指定了
    closable:true

我意识到我使用的是相当旧的Ext JS版本,但不幸的是,升级现在不是一个选项。

尝试在没有dash.css的情况下运行。在我使用ext-all.css进行的测试中,条纹消失,关闭按钮出现,保存按钮看起来像一个按钮

至于保存按钮的位置,FormPanel默认使用表单布局。改为使用表格布局,并将“保存”按钮设为一个项目,该按钮将显示在文本字段旁边:

var entitySearchForm = new Ext.form.FormPanel({

    title: "Basic Form",
    layout:'table',
    width: 425,
    frame: true,
    layoutConfig: {columns: 3},
    items: [
    new Ext.form.TextField({
        hideLabel: true,
        width: 275,
        colspan: 2,
        allowBlank: false
    }), {
        xtype: 'button',
        text: 'Save',
        handler: function() {/* submit code */}
    }]
});`

2.3.0? 我很同情你。非常感谢,桌子的布局效果好多了。您知道是否可以在文本字段和按钮之间留出一个小空间,这样它们就不会相互挤压?我不知道它是否在2.3中可用,但在3.4中,用于表格布局的
layoutConfig
有一个属性,
tablettrs
,看起来它允许指定cellpadding和其他属性。此外,可以在
cellCls
中指定特定于单元格的CSS类。见: