/*
 * Ext JS Library 2.2.1
 * Copyright(c) 2006-2009, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

Ext.onReady(function(){

    // NOTE: This is an example showing simple state management. During development,
    // it is generally best to disable state management as dynamically-generated ids
    // can change across page loads, leading to unpredictable results.  The developer
    // should ensure that stable state ids are set for stateful components in real apps.
    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

    
    // example of custom renderer function
    function change(val){
        if(val > 0){
            return '<span style="color:green;">' + val + '</span>';
        }else if(val < 0){
            return '<span style="color:red;">' + val + '</span>';
        }
        return val;
    }

    // example of custom renderer function
    function pctChange(val){
        if(val > 0){
            return '<span style="color:green;">' + val + '%</span>';
        }else if(val < 0){
            return '<span style="color:red;">' + val + '%</span>';
        }
        return val;
    }

    // create the data store
    var store = new Ext.data.SimpleStore({
        fields: [
           {name: 'status'},
           {name: 'examname'},
           {name: 'examdate'},
           {name: 'cost'},
		   {name: 'number'},
           {name: 'operat'}
        ]
    });
    store.loadData(myData);

    var h = window.screen.height;
	h=h-288;
	// create the Grid
    var grid = new Ext.grid.GridPanel({
        store: store,
        columns: [
            {id:'status',header: "状态", width: 50, sortable: true, dataIndex: 'status'},
            {header: "试卷名称", width: 400, sortable: true, dataIndex: 'examname'},
            {header: "考试时间", width: 150, sortable: true, dataIndex: 'examdate'},
            {header: "用时", width: 100, sortable: true, dataIndex: 'cost'},
            {header: "分数", width: 100, sortable: true, dataIndex: 'number'},
			{header: "操作", width: 140, sortable: false, dataIndex: 'operat'}
        ],
        stripeRows: true,
        autoExpandColumn: 'status',
        height:h,
        width:950,
        title:"<div align='center' >≡ 试 卷 列 表 ≡</div>"
    });

    grid.render('grid-example');
});
