javascript - Extjs itemId in class definition -


is bad practice have itemid configuration on class definition (instead of instantiation)?

is there official documentation backs or matter of opinion?

or maybe there logic i'm missing makes evident bad practice.

ext.define('someapp.view.somefolder.myspecialcomponent',{     extend: 'ext.panel.panel',     itemid: 'specialcomponent'     // ... }); 

because understand if there more 1 instance , use itemid selector both instances. let's know won't have more 1 instance @ time , let's instantiation can occur in 3 different places, don't want add itemid's in 3 different places , don't want itemid's different.

so there official posture using itemid configuration @ class definition?

from docs of ext.abstractcomponent.itemid:

an itemid can used alternative way reference component when no object reference available. instead of using id ext.getcmp, use itemid ext.container.container.getcomponent retrieve itemid's or id's. since itemid's index container's internal mixedcollection, itemid scoped locally container -- avoiding potential conflicts ext.componentmanager requires unique id.

since itemid used index, must unique within container. if added 2 instances of component have same itemid same container, second 1 overwrite first one.

you can observe behaviour in fiddle: https://fiddle.sencha.com/#fiddle/m2n

especially considering fact, in opinion not make sense specify itemid in class definition directly, because:

  • if wanted add more 1 instance of component same container, not work (unless overwrite itemid again upon instantiation).
  • if not case might want consider not specifying itemid @ all. instead instance xtype:

    // assuming xtype 'specialcomponent' container.query('specialcomponent') 
  • you'd hide itemid @ instantiation time, making more difficult understand comes from

    var ct = ext.create('ext.container.container', {     items: [{         // not clear have itemid 'specialcomponent'         xtype: 'specialcomponent'     },{         xtype: 'panel',         itemid: 'somepanel'     }]; 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -