PDA

View Full Version : How to display a grid instead of a menu from a toolbar button?



murrah
5 Jul 2009, 1:02 AM
SORRY, wrong forum. I have reposted in correct forum. How do you delete a post?

Hi,

I have a toolbar and I want to display a small grid instead of a menu when the user clicks the toolbar button.

I tried this and while it doesnt cause an errors it also doesnt display anything apart from the small square you normally get when you display a menu with no items. The grid works if I display it in a tab panel so I dont think the error is there but maybe some specific config options are required.

That is, of course, if this is possible in the first place !

The test grid:


var myData = [
['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
['Altria Group Inc',83.81,0.28,0.34,'9/1 12:00am']
]
var myStore = new Ext.data.SimpleStore({
fields: [
{name: 'company'},
{name: 'price', type: 'float'},
{name: 'change', type: 'float'},
{name: 'pctChange', type: 'float'},
{name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
]
});
myStore.loadData(myData);

tx.grid.myGrid = new Ext.grid.GridPanel({
store: myStore,
region:'center',
text:'mygrid',
hideMode :'offsets',
columns: [
{id:'company',header: "Company", width: 160, sortable: true, dataIndex: 'company'},
{header: "Price", width: 75, sortable: true, renderer: 'usMoney', dataIndex: 'price'},
{header: "Change", width: 75, sortable: true, dataIndex: 'change'},
{header: "% Change", width: 75, sortable: true, dataIndex: 'pctChange'},
{header: "Last Updated", width: 85, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
],
stripeRows: true,
autoExpandColumn: 'company',
height:350,
width:600,
title:'Array Grid'
});



The toolbar:



this.tbar = [
tx.actions.newFolder,
tx.actions.newList,
'-'
,{
text:'Reminders'
,menu: new Ext.menu.Menu({
text:'Reminders',
items: [tx.grid.myGrid]
})

}
];


I know I might be pushing it a bit here but is this possible? Or would I need to write a plugin?

Cheers,
Murray