3 * Copyright(c) 2006-2010 Sencha Inc.
5 * http://www.sencha.com/license
7 Ext.onReady(function(){
10 * Handler specified for the 'Available' column renderer
11 * @param {Object} value
13 function formatDate(value){
14 return value ? value.dateFormat('M d, Y') : '';
20 // the column model has information about grid columns
21 // dataIndex maps the column to the specific data field in
22 // the data store (created below)
23 var cm = new Ext.grid.ColumnModel({
24 // specify any defaults for each column
26 sortable: true // columns are not sortable by default
30 header: 'Common Name',
33 // use shorthand alias defined above
34 editor: new fm.TextField({
41 editor: new fm.ComboBox({
44 // transform the data already specified in html
47 listClass: 'x-combo-list-small'
55 editor: new fm.NumberField({
62 dataIndex: 'availDate',
65 editor: new fm.DateField({
69 disabledDaysText: 'Plants are not available on the weekends'
79 // create the Data Store
80 var store = new Ext.data.Store({
81 // destroy the store if the grid is destroyed
84 // load remote data using HTTP
87 // specify a XmlReader (coincides with the XML format of the returned data)
88 reader: new Ext.data.XmlReader({
89 // records will have a 'plant' tag
91 // use an Array of field definition objects to implicitly create a Record constructor
93 // the 'name' below matches the tag name to read, except 'availDate'
94 // which is mapped to the tag 'availability'
95 {name: 'common', type: 'string'},
96 {name: 'botanical', type: 'string'},
98 {name: 'price', type: 'float'},
99 // dates can be automatically converted by specifying dateFormat
100 {name: 'availDate', mapping: 'availability', type: 'date', dateFormat: 'm/d/Y'},
101 {name: 'indoor', type: 'bool'}
105 sortInfo: {field:'common', direction:'ASC'}
108 // create the editor grid
109 var grid = new Ext.grid.EditorGridPanel({
112 renderTo: 'editor-grid',
115 autoExpandColumn: 'common', // column with this id will be expanded
116 title: 'Edit Plants?',
121 handler : function(){
122 // access the Record constructor through the grid's store
123 var Plant = grid.getStore().recordType;
125 common: 'New Plant 1',
126 light: 'Mostly Shade',
128 availDate: (new Date()).clearTime(),
133 grid.startEditing(0, 0);
138 // manually trigger the data store load
140 // store loading is asynchronous, use a load listener or callback to handle results
141 callback: function(){
143 title: 'Store Load Callback',
144 msg: 'store was loaded, data available for processing',