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";
16 Roo.onReady(function(){
18 function formatBoolean(value){
19 return value ? 'Yes' : 'No';
22 function formatDate(value){
23 return value ? value.dateFormat('M d, Y') : '';
26 var fm = Roo.form, Ed = Roo.grid.GridEditor;
28 // the column model has information about grid columns
29 // dataIndex maps the column to the specific data field in
30 // the data store (created below)
31 var cm = new Roo.grid.ColumnModel([{
32 header: "Common Name",
35 editor: new Ed(new fm.TextField({
42 editor: new Ed(new Roo.form.ComboBox({
54 editor: new Ed(new fm.NumberField({
61 dataIndex: 'availDate',
64 editor: new Ed(new fm.DateField({
68 disabledDaysText: 'Plants are not available on the weekends'
74 renderer: formatBoolean,
75 editor: new Ed(new fm.Checkbox())
78 // by default columns are sortable
79 cm.defaultSortable = true;
81 // this could be inline, but we want to define the Plant record
82 // type so we can add records dynamically
83 var Plant = Roo.data.Record.create([
84 // the "name" below matches the tag name to read, except "availDate"
85 // which is mapped to the tag "availability"
86 {name: 'common', type: 'string'},
87 {name: 'botanical', type: 'string'},
89 {name: 'price', type: 'float'}, // automatic date conversions
90 {name: 'availDate', mapping: 'availability', type: 'date', dateFormat: 'm/d/Y'},
91 {name: 'indoor', type: 'bool'}
94 // create the Data Store
95 var ds = new Roo.data.Store({
97 proxy: new Roo.data.HttpProxy({url: 'plants.xml'}),
100 // the return will be XML, so lets set up a reader
101 reader: new Roo.data.XmlReader({
102 // records will have a "plant" tag
107 // create the editor grid
108 grid = new Roo.grid.EditorGrid('editor-grid', {
115 var layout = Roo.BorderLayout.create({
117 margins:{left:3,top:3,right:3,bottom:3},
118 panels: [new Roo.GridPanel(grid)]
127 var gridHead = grid.getView().getHeaderPanel(true);
128 var tb = new Roo.Toolbar(gridHead, [{
130 handler : function(){
132 common: 'New Plant 1',
133 light: 'Mostly Shade',
135 availDate: new Date(),
140 grid.startEditing(0, 0);
144 // trigger the data store load