4 Ext.Loader.setPath('Ext.ux', '../ux');
7 'Ext.selection.CellModel',
16 Ext.onReady(function(){
18 function formatDate(value){
19 return value ? Ext.Date.dateFormat(value, 'M d, Y') : '';
23 extend: 'Ext.data.Model',
25 // the 'name' below matches the tag name to read, except 'availDate'
26 // which is mapped to the tag 'availability'
27 {name: 'common', type: 'string'},
28 {name: 'botanical', type: 'string'},
30 {name: 'price', type: 'float'},
31 // dates can be automatically converted by specifying dateFormat
32 {name: 'availDate', mapping: 'availability', type: 'date', dateFormat: 'm/d/Y'},
33 {name: 'indoor', type: 'bool'}
38 // create the Data Store
39 var store = Ext.create('Ext.data.Store', {
40 // destroy the store if the grid is destroyed
45 // load remote data using HTTP
47 // specify a XmlReader (coincides with the XML format of the returned data)
50 // records will have a 'plant' tag
60 var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
64 // create the grid and specify what field you want
65 // to use for the editor at each header.
66 var grid = Ext.create('Ext.grid.Panel', {
70 header: 'Common Name',
87 ['Mostly Shady','Mostly Shady'],
88 ['Sun or Shade','Sun or Shade'],
89 ['Mostly Sunny','Mostly Sunny'],
93 listClass: 'x-combo-list-small'
102 xtype: 'numberfield',
109 dataIndex: 'availDate',
111 renderer: formatDate,
115 minValue: '01/01/06',
116 disabledDays: [0, 6],
117 disabledDaysText: 'Plants are not available on the weekends'
120 xtype: 'checkcolumn',
128 renderTo: 'editor-grid',
131 title: 'Edit Plants?',
135 handler : function(){
136 // Create a record instance through the ModelManager
137 var r = Ext.ModelManager.create({
138 common: 'New Plant 1',
139 light: 'Mostly Shady',
141 availDate: Ext.Date.clearTime(new Date()),
145 cellEditing.startEditByPosition({row: 0, column: 0});
148 plugins: [cellEditing]
151 // manually trigger the data store load
153 // store loading is asynchronous, use a load listener or callback to handle results
154 callback: function(){
156 title: 'Store Load Callback',
157 msg: 'store was loaded, data available for processing',