PDA

View Full Version : Dynamic Ajax Grid.



coolstar
12 Jan 2010, 8:24 PM
Hi all. I'm trying to create an ajax grid that is dynamic(you can switch the url of the xml file, and rerender the grid without reopening the Ext Window). Can you help me?

Code:
GetModules:

new MyDesktop.ExplorerWindow(),
Module:

var filegrid;
var fileurl = '../../fileman.php?dir=/applications';
var filestore;
MyDesktop.ExplorerWindow = Ext.extend(Ext.app.Module, {
id:'explorer-win',
init : function(){
this.launcher = {
text: 'File Explorer',
iconCls:'tabs',
handler : this.createWindow,
scope: this
}
},

createWindow : function(){
filestore = new Ext.data.Store({
// load using HTTP
url: fileurl,
// the return will be XML, so lets set up a reader
reader: new Ext.data.XmlReader({
// records will have an "Item" tag
record: 'file',
id: 'file',
totalRecords: '@total'
}, [
// set up the fields mapping into the xml doc
// The first needs mapping, the others are very basic
{name: 'name', mapping: 'name'},
'name', 'type'
])
});
filestore.load();
filegrid = new Ext.grid.GridPanel({
store: filestore,
columns: [
{header: "Name", width: 120, dataIndex: 'name', sortable: true},
{header: "Type", width: 180, dataIndex: 'type', sortable: true}
]
});
var desktop = this.app.getDesktop();
var win = desktop.getWindow('explorer-win');
if(!win){
win = desktop.createWindow({
id: 'explorer-win',
title:'File Explorer',
width:420,
height:390,
iconCls: 'tabs',
shim:false,
animCollapse:false,
border:false,
constrainHeader:true,
minimizable: false,
maximizable: false,
resizable: false,

layout: 'fit',
items: [ filegrid ]

});
}
win.show();
}
});

Using: Extjs 3.1 Desktop
Php 5

coolstar
17 Jan 2010, 12:30 AM
I already found out how to do so:


filestore.proxy.conn.url=fileurl;filestore.load();

17 Jan 2010, 10:58 AM
the better way is filestore.load({url:fileurl});