4 * Copyright(c) 2006-2007, Ext JS, LLC.
6 * Originally Released Under LGPL - original licence link has changed is not relivant.
9 * <script type="text/javascript">
12 Roo.BLANK_IMAGE_URL = "../../images/default/s.gif";
14 Roo.onReady(function(){
\r
15 Roo.QuickTips.init();
\r
16 function formatBoolean(value){
\r
17 return value ? 'Yes' : 'No';
\r
20 function formatDate(value){
\r
21 return value ? value.dateFormat('M d, Y') : '';
\r
24 var fm = Roo.form, Ed = Roo.grid.GridEditor;
\r
26 // the column model has information about grid columns
\r
27 // dataIndex maps the column to the specific data field in
\r
28 // the data store (created below)
\r
29 var cm = new Roo.grid.ColumnModel([{
\r
30 header: "Common Name",
\r
31 dataIndex: 'common',
\r
33 editor: new Ed(new fm.TextField({
\r
40 editor: new Ed(new Roo.form.ComboBox({
\r
42 triggerAction: 'all',
\r
51 renderer: 'usMoney',
\r
52 editor: new Ed(new fm.NumberField({
\r
54 allowNegative: false,
\r
58 header: "Available",
\r
59 dataIndex: 'availDate',
\r
61 renderer: formatDate,
\r
62 editor: new Ed(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
70 dataIndex: 'indoor',
\r
72 renderer: formatBoolean,
\r
73 editor: new Ed(new fm.Checkbox())
\r
76 // by default columns are sortable
\r
77 cm.defaultSortable = true;
\r
79 // this could be inline, but we want to define the Plant record
\r
80 // type so we can add records dynamically
\r
81 var Plant = Roo.data.Record.create([
\r
82 // the "name" below matches the tag name to read, except "availDate"
\r
83 // which is mapped to the tag "availability"
\r
84 {name: 'common', type: 'string'},
\r
85 {name: 'botanical', type: 'string'},
\r
87 {name: 'price', type: 'float'}, // automatic date conversions
\r
88 {name: 'availDate', mapping: 'availability', type: 'date', dateFormat: 'm/d/Y'},
\r
89 {name: 'indoor', type: 'bool'}
\r
92 // create the Data Store
\r
93 var ds = new Roo.data.Store({
\r
95 proxy: new Roo.data.HttpProxy({url: 'plants.xml'}),
\r
97 // the return will be XML, so lets set up a reader
\r
98 reader: new Roo.data.XmlReader({
\r
99 // records will have a "plant" tag
\r
104 // create the editor grid
\r
105 var grid = new Roo.grid.EditorGrid('editor-grid', {
\r
108 enableColLock:false
\r
111 var layout = Roo.BorderLayout.create({
\r
113 margins:{left:3,top:3,right:3,bottom:3},
\r
114 panels: [new Roo.GridPanel(grid)]
\r
123 var gridHead = grid.getView().getHeaderPanel(true);
\r
124 var tb = new Roo.Toolbar(gridHead, [{
\r
126 handler : function(){
\r
127 var p = new Plant({
\r
128 common: 'New Plant 1',
\r
129 light: 'Mostly Shade',
\r
131 availDate: new Date(),
\r
134 grid.stopEditing();
\r
136 grid.startEditing(0, 0);
\r
140 // trigger the data store load
\r