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",
36 editor: new Ed(new fm.TextField({
43 editor: new Ed(new Roo.form.ComboBox({
55 editor: new Ed(new fm.NumberField({
62 dataIndex: 'availDate',
65 editor: new Ed(new fm.DateField({
69 disabledDaysText: 'Plants are not available on the weekends'
75 renderer: formatBoolean,
76 editor: new Ed(new fm.Checkbox())
79 // by default columns are sortable
80 cm.defaultSortable = true;
82 // this could be inline, but we want to define the Plant record
83 // type so we can add records dynamically
84 var Plant = Roo.data.Record.create([
85 // the "name" below matches the tag name to read, except "availDate"
86 // which is mapped to the tag "availability"
87 {name: 'common', type: 'string'},
88 {name: 'botanical', type: 'string'},
90 {name: 'price', type: 'float'}, // automatic date conversions
91 {name: 'availDate', mapping: 'availability', type: 'date', dateFormat: 'm/d/Y'},
92 {name: 'indoor', type: 'bool'}
95 // create the Data Store
96 var ds = new Roo.data.Store({
98 proxy: new Roo.data.HttpProxy({url: 'plants.xml'}),
101 // the return will be XML, so lets set up a reader
102 reader: new Roo.data.XmlReader({
103 // records will have a "plant" tag
108 // create the editor grid
109 grid = new Roo.grid.EditorGrid('editor-grid', {
114 enableDragDrop : true,
116 enddrag : function(g, dd, targetid , e) {
119 dragdrop : function(g, dd, targetid , e) {
122 dragover : function(g, dd, targetid , e) {
125 dragenter : function(g, dd, targetid , e) {
126 Roo.log('dragenter');
128 dragout : function(g, dd, targetid , e) {
137 var layout = Roo.BorderLayout.create({
139 margins:{left:3,top:3,right:3,bottom:3},
140 panels: [new Roo.GridPanel(grid)]
149 var gridHead = grid.getView().getHeaderPanel(true);
150 var tb = new Roo.Toolbar(gridHead, [{
152 handler : function(){
154 common: 'New Plant 1',
155 light: 'Mostly Shade',
157 availDate: new Date(),
162 grid.startEditing(0, 0);
166 // trigger the data store load