X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775:/examples/grid/array-grid.js diff --git a/examples/grid/array-grid.js b/examples/grid/array-grid.js index 1d9c0654..746f9e6c 100644 --- a/examples/grid/array-grid.js +++ b/examples/grid/array-grid.js @@ -1,5 +1,5 @@ /*! - * Ext JS Library 3.0.0 + * Ext JS Library 3.0.3 * Copyright(c) 2006-2009 Ext JS, LLC * licensing@extjs.com * http://www.extjs.com/license @@ -12,6 +12,7 @@ Ext.onReady(function(){ // should ensure that stable state ids are set for stateful components in real apps. Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); + // sample static data for the store 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'], @@ -44,7 +45,10 @@ Ext.onReady(function(){ ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am'] ]; - // example of custom renderer function + /** + * Custom function used for column renderer + * @param {Object} val + */ function change(val){ if(val > 0){ return '' + val + ''; @@ -54,7 +58,10 @@ Ext.onReady(function(){ return val; } - // example of custom renderer function + /** + * Custom function used for column renderer + * @param {Object} val + */ function pctChange(val){ if(val > 0){ return '' + val + '%'; @@ -74,23 +81,30 @@ Ext.onReady(function(){ {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'} ] }); + + // manually load local data store.loadData(myData); // create the Grid var grid = new Ext.grid.GridPanel({ store: store, 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, renderer: change, dataIndex: 'change'}, - {header: "% Change", width: 75, sortable: true, renderer: pctChange, dataIndex: 'pctChange'}, - {header: "Last Updated", width: 85, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'} + {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, renderer: change, dataIndex: 'change'}, + {header: '% Change', width: 75, sortable: true, renderer: pctChange, 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' + height: 350, + width: 600, + title: 'Array Grid', + // config options for stateful behavior + stateful: true, + stateId: 'grid' }); + + // render the grid to the specified div in the page grid.render('grid-example'); }); \ No newline at end of file