i would like to add a new div tag by clicking a button, but it doesnt work. I have a web desktop from extjs and two modules. One window like the following code, with 1 div [20,20]. And a second window with a button 开发者_StackOverflowand handler to add a new div tag in the first window. But it doesnt work.
win = desktop.createWindow({
id: 'firstwindow',
title: 'firstwindow',
width: 421,
height: 391,
divs: [{
x: 20,
y: 20
}],
and so on..
and here the code for adding a div in the firstwindow by clicking button in the second window
handler: function(){
if (Ext.getCmp('firstwindow')) {
Ext.getCmp('firstwindow').add({
divs: [{
x: 20,
y: 40
}]
})
Ext.getCmp('firstwindow').render();
console.log(Ext.getCmp('firstwindow'));
}
}
Thanks in advance, cheers, Thomas
The add method you are using is used to add a ExtJs component into the container (in your case its Window). You cannot create a DIV tag using the add method.
In ExtJS you can create a component and add it to the container. If you need to modify the DOM, you will have to update the el property. By default, in ExtJS its a DIV tag. You can override this by the autoEl config.
A possible solution:
Now, If you want to repeatedly create a DIV tag with some content in it and rendered dynamically, you can take the help of DataView. Create a Template with your DIV and its child.. load data into the store and finally render them or update DataView in your window.
I think you must use Ext.getCmp('firstwindow').doLayout() instead of Ext.getCmp('firstwindow').render()
精彩评论