
Ext.onReady(function(){
	
	function formatDate(value){
        return value ? value.dateFormat('F j') : '';
    };

    Ext.QuickTips.init();
    
    var xg = Ext.grid;

    // shared reader
    var reader = new Ext.data.ArrayReader({}, [
       {name: 'name'},
       {name: 'type'},
       {name: 'date', type: 'date', dateFormat: 'F j'}
    ]);

    ////////////////////////////////////////////////////////////////////////////////////////
    // Grid 1
    ////////////////////////////////////////////////////////////////////////////////////////
    // row expander
    var expander = new xg.RowExpander({
        tpl : new Ext.Template(
            '<p><b>Description:</b> {desc}</p>'
        )
    });

    var grid1 = new xg.GridPanel({
        store: new Ext.data.GroupingStore({
            reader: reader,
            data: xg.dummyData,
			sortInfo:{field: 'date', direction: "ASC"},
            groupField:'type'
        }),
        cm: new xg.ColumnModel([
            expander,
            {id:'name',header: "Name", width: 60, sortable: false, dataIndex: 'name'},
            {header: "Type", width: 40, sortable: false, dataIndex: 'type'},
            {header: "Date", width: 40, sortable: false, renderer: Ext.util.Format.dateRenderer('F j'), dataIndex: 'date'}
        ]),
		
		view: new Ext.grid.GroupingView({
            forceFit:true,
            groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'
        }),
		
        viewConfig: {
            forceFit:true
        },
        width: 540,
        height: 740,
        collapsible: false,
        animCollapse: false,
        title: 'Peach Varieties with Descriptions',
        iconCls: 'icon-grid',
        renderTo:'peach-grid'
    });




});



// Array data for the grids
Ext.grid.dummyData = [
    ['Gold Crest','Cling','May 13',''],
	['Rich May','Cling','May 18',''],
	['Caro Red','Cling','May 18',''],
	['Regal','Cling','May 20',''],
	['Ezzies Sweet (Ham Variety)','Cling','May 20',''],
	['Sunbrite','Cling','May 24',''],
	['Empress','Cling','May 24',''],
	['PF-5D','Cling','May 24',''],
	['CVN I','Cling','June 12',''],
	['June Gold','Cling','June 11',''],
	['Ruby Prince','Cling','June 11',''],
	['Surecrop','Cling','June 15',''],
	['Garnet Beauty','Cling','June 15',''],
	['Flavor Crest','Cling','June 15',''],
	['PF-7A','Cling','June 15',''],
	['Cornet','Cling','June 22',''],
	['Gala','Cling','June 25',''],
	['Sentinel','Cling','June 25',''],
	['R.L. Special','Cling','June 28',''],
	['Sugar May','White Flesh','June 3',''],
	['Snowbrite','White Flesh','June 19',''],
	['White Lady','White Flesh','June 24',''],
	['White County','White Flesh','June 26',''],
	['White River','White Flesh','July 1',''],
	['Sugar Giant','White Flesh','July 15',''],
	['Snow Giant','White Flesh','August 7',''],
	['Harvester','Freestone','June 23',''],
	['Cary Mac','Freestone','June 25',''],
	['PF-11','Freestone','June 25',''],
	['Fire Prince','Freestone','June 18',''],
	['Majestic','Freestone','June 25',''],
	['Red Gold','Freestone','July 1',''],
	['Loring','Freestone','July 4',''],
	['PF24-007','Freestone','July 5',''],
	['Bounty','Freestone','July 5',''],
	['Early August Prince','Freestone','July 13',''],
	['Dixieland','Freestone','July 15',''],
	['Red Skin','Freestone','July 15',''],
	['Sun Prince','Freestone','July 18',''],
	['Jefferson','Freestone','August 1',''],
	['Taylors Treat (Ham Variety)','Freestone','August 1',''],
	['August Prince','Freestone','August 3',''],
	['Ouachita Gold','Freestone','August 3',''],
	['PF 28-007','Freestone','August 4',''],
	['O\'Henry','Freestone','August 8',''],
	['Encore','Freestone','August 8',''],
	['PF 35-007','Freestone','August 10',''],
	['Flame Prince','Freestone','August 12','']
];

