Search code examples
extjsextjs4

ExtJs the same id and itemId


I've got old project written in ExtJs 4.2 and I'm trying to make it more component oriented.

For example I've got the following existing code:

Ext.define("CCH3.view.motivationschema.DealersTab", {
    extend: "Ext.panel.Panel",
    xtype: "dealerstab",
    title: "Dealers",
    store: "admin.Users",

    layout: {
        type: "border"
    },

    region: "center",
    xtype: "tabpanel",
    layout: { type: "vbox", align: "stretch" },
    items: [
        {
            xtype: "panel",
            layout: { type: "vbox", align: "stretch" },
            title: "Region dealers",
            items: [
                {
                     xtype: "panel",
                     flex: 1,
                     items: [
                         {
                              id: "tab-region-dealers",
                              xtype: "salepoint"
                         }
                     ]
                  }, 
                  {
                      xtype: "tabpanel",
                      flex: 2,
                      items: [
                          {
                               id: "tab-operator-list",
                               title: "Operator list",
                               xtype: "operator"
                           }
                       ]
                    }
               ]
         }
]});

So I want to add itemId property will it break my project if I use the same id and itemId property?


Solution

  • No, it won't break. They are not mutually exclusive. You just have to follow these 2 rules:

    1. itemId should be unique within it's container;
    2. id should be unique across all existing components.

    In the long run, I would suggest getting rid of ids.