3 * Copyright(c) 2006-2009 Ext JS, LLC
5 * http://www.extjs.com/license
7 Ext.onReady(function(){
\r
8 Ext.QuickTips.init();
\r
10 function formatDate(value){
\r
11 return value ? value.dateFormat('M d, Y') : '';
\r
16 // custom column plugin example
\r
17 var checkColumn = new Ext.grid.CheckColumn({
\r
19 dataIndex: 'indoor',
\r
23 // the column model has information about grid columns
\r
24 // dataIndex maps the column to the specific data field in
\r
25 // the data store (created below)
\r
26 var cm = new Ext.grid.ColumnModel([{
\r
28 header: 'Common Name',
\r
29 dataIndex: 'common',
\r
31 // use shorthand alias defined above
\r
32 editor: new fm.TextField({
\r
39 editor: new fm.ComboBox({
\r
41 triggerAction: 'all',
\r
44 listClass: 'x-combo-list-small'
\r
51 renderer: 'usMoney',
\r
52 editor: new fm.NumberField({
\r
54 allowNegative: false,
\r
58 header: 'Available',
\r
59 dataIndex: 'availDate',
\r
61 renderer: formatDate,
\r
62 editor: new fm.DateField({
\r
64 minValue: '01/01/06',
\r
65 disabledDays: [0, 6],
\r
66 disabledDaysText: 'Plants are not available on the weekends'
\r
72 // by default columns are sortable
\r
73 cm.defaultSortable = true;
\r
75 // create the Data Store
\r
76 var store = new Ext.data.Store({
\r
77 // load remote data using HTTP
\r
80 // specify a XmlReader (coincides with the XML format of the returned data)
\r
81 reader: new Ext.data.XmlReader(
\r
83 // records will have a 'plant' tag
\r
86 // use an Array of field definition objects to implicitly create a Record constructor
\r
88 // the 'name' below matches the tag name to read, except 'availDate'
\r
89 // which is mapped to the tag 'availability'
\r
90 {name: 'common', type: 'string'},
\r
91 {name: 'botanical', type: 'string'},
\r
93 {name: 'price', type: 'float'},
\r
94 // dates can be automatically converted by specifying dateFormat
\r
95 {name: 'availDate', mapping: 'availability', type: 'date', dateFormat: 'm/d/Y'},
\r
96 {name: 'indoor', type: 'bool'}
\r
100 sortInfo: {field:'common', direction:'ASC'}
\r
103 // create the editor grid
\r
104 var grid = new Ext.grid.EditorGridPanel({
\r
107 renderTo: 'editor-grid',
\r
110 autoExpandColumn: 'common',
\r
111 title: 'Edit Plants?',
\r
113 plugins: checkColumn,
\r
117 handler : function(){
\r
118 // access the Record constructor through the grid's store
\r
119 var Plant = grid.getStore().recordType;
\r
120 var p = new Plant({
\r
121 common: 'New Plant 1',
\r
122 light: 'Mostly Shade',
\r
124 availDate: (new Date()).clearTime(),
\r
127 grid.stopEditing();
\r
128 store.insert(0, p);
\r
129 grid.startEditing(0, 0);
\r
134 // trigger the data store load
\r