PDA

View Full Version : Create a tbar-button within an ajax request



Snoop74
14 Oct 2010, 11:43 AM
Hello.

I need to add some buttons to my tbar (grid) dynamically. due to this, i use the following code:


Ext.Ajax.request({
url: 'test.php',
params: {
"action": "getData",
},
success: function(response) {
var obj = Ext.decode(response.responseText);

for (day in obj.data)
if (!isNaN(parseFloat(day))) {
var btntxt = obj.data[day];
var btn = new Ext.Button({text: btntxt});
Ext.getCmp("testTBar").toolbars[0].insertButton(3,btn);
}
}
});

This will not work, but ...


var btn = new Ext.Button({text: "TEST"});
Ext.getCmp("testTBar").toolbars[0].insertButton(3,btn);

is working fine. Of course, the php script is delivering correct data - i checked this several times now and some other ajax requests can work with the given data fine.

What am i doing wrong ?

Animal
14 Oct 2010, 9:26 PM
After adding to a rendered Container, you must call doLayout on the Container which will then ask its layout manager to ensure all child Components are rendered, arranged and sized correctly according to the layout's type and configuration.

Snoop74
14 Oct 2010, 9:35 PM
Thanks !!
That was the solution.

Sone quite often - why i've forgotten that command here, no idea :o(

Thanks a lot, animal (as so often !)