无法将项目添加到extjs中的tab.panel

时间:2016-04-04 09:35:11

标签: extjs

对extjs 4.2很新。为我的项目做一个POC。

Just stuck at a point where am trying to add few more items to the tabs.
Please find the code below.
In tab1 I want add a textfield.
But its not allowing and throwing a syntax error.


#######
    Ext.onReady(function () {
    var textName={xtype:"textfield",fieldLabel:"username",margin:"10 10"};
    var tabObj=Ext.create("Ext.tab.Panel",{
    title: "Registration Form",
    margin:"10 10 10 40",
    plain:"false",
    tabPosition:"bottom",
    items : [ 
      {
        title:"home",
        html:"This is from Home Tab",
       // xtype:"textfield",fieldLabel:"username",margin:"10 10"}
       //textName
      },
      {
        title:"services"
      },
      {
        title:"stock"
      }
    ],
    renderTo:Ext.getBody()
     });
   });
#######

在docs中得不到多少帮助。     在文档中,示例仅显示添加更多带有html属性的选项卡,而不是向选项卡添加更多组件。     请帮助我。

1 个答案:

答案 0 :(得分:0)

也许你错过了items

例如:

Ext.onReady(function() {
        var textName = {
            xtype: "textfield",
            fieldLabel: "username",
            margin: "10 10"
        };
        var tabObj = Ext.create("Ext.tab.Panel", {
            title: "Registration Form",
            margin: "10 10 10 40",
            plain: "false",
            tabPosition: "bottom",
            items: [{
                title: "home",
                items: [
                    textName
                ]
            }, {
                title: "services"
            }, {
                title: "stock"
            }],
            renderTo: Ext.getBody()
        });
    });

一个工作示例:https://fiddle.sencha.com/#fiddle/1854