View Full Version : Reloading different data into a grid

2 Mar 2007, 8:51 AM
So I had the need display different versions of similar data in a grid on a single page. Originally I had created 3 different grids on 3 seperate tabs but had the idea instead to a single grid and add toolbar buttons to switch the data around.

Here's the solution i came up with - it works - but thought I'd bounce it off other people to see if it's a "correct" way to do it. (Ext has given me reason / motivation to actually learn JS instead of just hacking my way through some script every few months)

var tb = new Ext.Toolbar(gridHead); // So create my toolbar buttons and assign handlers
id: 'btn_unscheduled',
text: 'Unscheduled Fittings',
handler: unscheduled
}, '-',
id: 'btn_scheduled',
text: 'Scheduled Fittings',
handler: scheduled
}, '-',
id: 'btn_completed',
text: 'Completed Fittings',
handler: completedFittings

// then later on in my code - here are the handlers for those buttons where I merely reassign the proxy assigned to the ds variable

function unscheduled() {
Ext.apply(ds, { proxy: new Ext.data.MemoryProxy(unscheduled)});
// repeat for other handlers

Right now I'm just using arrays in memory while the external data is being finalized but I assume it should work for an xml or json proxy as well.

So acceptable solution or hideous hack?

2 Mar 2007, 8:58 AM
It looks fine to me in the all have the same record type. This line can be changed:

Ext.apply(ds, { proxy: new Ext.data.MemoryProxy(unscheduled)});


ds.proxy = new Ext.data.MemoryProxy(unscheduled);