
LSPN.MainPage.prototype.setupSeasonStrokeStats = function()
{
	var ds = new Ext.data.Store({
    	    proxy: new Ext.data.HttpProxy(new JayRock.RpcConnection({url:RPC_URL, rpcMethod:'getSeasonStrokeStats'})),
    	    method: "POST",
    	    sortInfo : {field: "average_score", direction: "ASC"},
            remoteSort: true,
            baseParams: {league_id: league_detail_id},
            reader: new Ext.data.JsonReader({
            root: 'rows',
            totalProperty: 'num_records',
			fields: ["username", "user_id", "average_score", "holes", "rounds", "holesinone", "doubleeagles", "eagles", "birdies", "pars", "bogies", "other", "hits_par_3", "hits_par_4", "hits_par_5", "chips_per_round", "mulligans_per_round"]
           })
    });
    
    // the column model has information about grid columns
    // dataIndex maps the column to the specific data field in
    // the data store
		
    
    var cm = new Ext.grid.ColumnModel([{
           header: "Player",
           dataIndex: 'username',
           width: 90
        },{
           header: "Avg Score",
           dataIndex: 'average_score',
           width: 70
        },{
           header: "Holes",
           dataIndex: 'holes',
           width: 50,
           align: 'left'
        },{
           header: "Rds",
           dataIndex: 'rounds',
           width: 50,
           align: 'left'
        },{
           header: "Aces",
           dataIndex: 'holesinone',
           width: 50,
           align: 'left'
        },{
           header: "Dbl Egls",
           dataIndex: 'doubleeagles',
           width: 50,
           align: 'left'
        },{
           header: "Egls",
           dataIndex: 'eagles',
           width: 50,
           align: 'left'
        },{
           header: "Brds",
           dataIndex: 'birdies',
           width: 50,
           align: 'left'
        },{
           header: "Pars",
           dataIndex: 'pars',
           width: 50,
           align: 'left'
        },{
           header: "Bgs",
           dataIndex: 'bogies',
           width: 50,
           align: 'left'
        },{
           header: "Other",
           dataIndex: 'other',
           width: 50,
           align: 'left'
        },{
           header: "Par3s",
           dataIndex: 'hits_par_3',
           width: 50,
           align: 'left',
           renderer: renderAvgPoints
        },{
           header: "Par4s",
           dataIndex: 'hits_par_4',
           width: 50,
           align: 'left',
           renderer: renderAvgPoints
        },{
           header: "Par5s",
           dataIndex: 'hits_par_5',
           width: 50,
           align: 'left',
           renderer: renderAvgPoints
        }]);

    // by default columns are sortable
    cm.defaultSortable = true;

    var grid = new Ext.grid.GridPanel({
        applyTo:'stats-stroke-grid',
        width:630,
        height:300,
        store: ds,
        cm: cm,
        stripeRows: true,
        loadMask: true,
        viewConfig: {
            forceFit:true,
            enableRowBody:true,
            showPreview:true
        },
        bbar: new Ext.PagingToolbar({
        	id: 'page-stats-stroke',
            pageSize: 25,
            store: ds,
            displayInfo: true,
            displayMsg: 'Displaying players {0} - {1} of {2}',
            emptyMsg: "No players to display"
        })
    });

    grid.on('rowdblclick', this.showProfile, this);
    
    // render it
    grid.render();

    // trigger the data store load
    ds.load({params:{start:0, limit:25}});

}
