ExtJS组件 - GridPanel ②

Ext.onReady(function(){
//	Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
	Ext.BLANK_IMAGE_URL = '../ext-2.2/resources/images/default/s.gif';
//	Json
	var myData = 
		[
			{name:'程仁银',sex:'男',age:'25'},
			{name:'王  佩',sex:'女',age:'44'},
			{name:'姜  新',sex:'男',age:'32'}
		];
//	JsonStore
	var store = new Ext.data.JsonStore({
		data:myData,	//	store.loadData(myData);
		fields:['name','sex','age']
	});
//	load data
//	store.loadData(myData);
//	columns
	var colM = new Ext.grid.ColumnModel(
		[
        	{header: "姓名",sortable: true, dataIndex: 'name'},
            {header: "性别",sortable: true,dataIndex: 'sex'}, //	renderer: fn
            {header: "年龄",sortable: true,dataIndex: 'age'}
		]
	);	
//	create new grid
	var grid = new Ext.grid.GridPanel({
		store:store,
		cm:colM,
        stripeRows: true, // 隔行换色
        height:350,
        width:600,
        title:'Array Grid'
	});
	grid.render('grid-example');
	grid.getSelectionModel().selectFirstRow();
});

你可能感兴趣的:(json,ext)