PDA

View Full Version : Load component from server



anpegar
28 Mar 2011, 8:54 AM
Hi, I need load a grid into a panel dynamically, I build the grid in my server with php and I want to load with a url. It's possible? Anyone have any example?

Thanks in advance.

kohyea
28 Mar 2011, 12:33 PM
Yes, sure

you need to load the scripts from server after the panel is render, and add to the panel, it depends on what is your scripts returned from server.

Kohyea

brittongr
28 Mar 2011, 4:42 PM
Yes, i do it using this code:


Ext.Ajax.request(
{
url: "here your url",
success: function (xhr) {
try {
var newComponent = eval(xhr.responseText);
//add the new component to panel or container
}
catch (ex) {
alert('Exception ' + ex);
}

},
failure: function () {
alert('failure');

}
});



and the returned javascript looks like this:


(function ()
{
return new Ext.Panel({
title: 'Panel dynamically loaded',
items: [new Ext.form.TextField({})]
});
})();


Hope it helps!

anpegar
28 Mar 2011, 10:22 PM
Hi brittongr, I think I will serve, thank you for you help.