admin管理员组文章数量:1023856
I use ExtJs 4.1 and DeftJs.
When using multiple instances of the same views at the same time, there is a problem addressing a ponent given the id: 'abc'
since all instances will have the same id.
So how do I name the ids to prevent this?
One option is to create the ponents dynamically.
Another option that I would prefer is calling an ponent by id only of a certain view, like:
this.getView.getComponent('x').getId('abc')
I use ExtJs 4.1 and DeftJs.
When using multiple instances of the same views at the same time, there is a problem addressing a ponent given the id: 'abc'
since all instances will have the same id.
So how do I name the ids to prevent this?
One option is to create the ponents dynamically.
Another option that I would prefer is calling an ponent by id only of a certain view, like:
this.getView.getComponent('x').getId('abc')
2 Answers
Reset to default 3If you can set the parent element to a unique id, you can use the itemId property on child items. Example of this from sencha's documentation (taken from the link below it):
var c = new Ext.panel.Panel({ //
height: 300,
renderTo: document.body,
layout: 'auto',
items: [
{
itemId: 'p1',
title: 'Panel 1',
height: 150
},
{
itemId: 'p2',
title: 'Panel 2',
height: 150
}
]
})
p1 = c.getComponent('p1'); // not the same as Ext.getCmp()
p2 = p1.ownerCt.getComponent('p2'); // reference via a sibling
http://docs.sencha./ext-js/4-0/#!/api/Ext.AbstractComponent-cfg-itemId
I try to avoid global ids and use this.getView().getComponent()
from a controller to access my view. If necessary I additionally use a unique string in my id name.
I use ExtJs 4.1 and DeftJs.
When using multiple instances of the same views at the same time, there is a problem addressing a ponent given the id: 'abc'
since all instances will have the same id.
So how do I name the ids to prevent this?
One option is to create the ponents dynamically.
Another option that I would prefer is calling an ponent by id only of a certain view, like:
this.getView.getComponent('x').getId('abc')
I use ExtJs 4.1 and DeftJs.
When using multiple instances of the same views at the same time, there is a problem addressing a ponent given the id: 'abc'
since all instances will have the same id.
So how do I name the ids to prevent this?
One option is to create the ponents dynamically.
Another option that I would prefer is calling an ponent by id only of a certain view, like:
this.getView.getComponent('x').getId('abc')
2 Answers
Reset to default 3If you can set the parent element to a unique id, you can use the itemId property on child items. Example of this from sencha's documentation (taken from the link below it):
var c = new Ext.panel.Panel({ //
height: 300,
renderTo: document.body,
layout: 'auto',
items: [
{
itemId: 'p1',
title: 'Panel 1',
height: 150
},
{
itemId: 'p2',
title: 'Panel 2',
height: 150
}
]
})
p1 = c.getComponent('p1'); // not the same as Ext.getCmp()
p2 = p1.ownerCt.getComponent('p2'); // reference via a sibling
http://docs.sencha./ext-js/4-0/#!/api/Ext.AbstractComponent-cfg-itemId
I try to avoid global ids and use this.getView().getComponent()
from a controller to access my view. If necessary I additionally use a unique string in my id name.
本文标签: javascriptExtJshow to set id of component when using multiple instancesStack Overflow
版权声明:本文标题:javascript - ExtJs - how to set id of component when using multiple instances - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745507095a2153655.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论