PDA

View Full Version : Fetching viewport components through Ajax



obelixextjs
29 Jun 2008, 10:38 AM
Hi

I am a noob w.r.to Ext JS. Trying to learn the toolkit.

I saw the portal demo and I am trying to use the Viewport with Ajax.

What I want to do is to fill in various parts of the viewport by different Ajax calls.

I see code like this that instantiates items inside the viewport.

items: [{
html: Ext.example.navigationMarkup,
title:'Navigation',
autoScroll:true,
border:false,
iconCls:'nav'
},{
title:'Settings',
html: Ext.example.shortBogusMarkup,
border:false,
autoScroll:true,
iconCls:'settings'
}]

Is there a way to fetch the html from the server by making an Ajax call and not invoke a Javascript method?

Any help is appreciated.

hendricd
29 Jun 2008, 11:29 AM
Panels have load methods and autoLoad config options. See the API reference for more.

obelixextjs
29 Jun 2008, 11:40 AM
Ah, panel. Thanks. I was looking in the Component hierarchy.

obelixextjs
29 Jun 2008, 5:44 PM
Thanks, that worked for HTML data.

Do you have any pointers to do lazy creation of Grids by using Ajax?

Thanks again.

evant
29 Jun 2008, 6:38 PM
Use a normal ajax request, eg:



Ext.Ajax.request(
{
url: 'foo',
success: function(response)
{
var o = Ext.decode(response.responseText);
myContainer.add(o);
myContainer.doLayout();
}
}
);


Your ajax request should return something like:



{
xtype: 'grid',
title: '...'
}

obelixextjs
29 Jun 2008, 9:46 PM
Thanks a lot.