roojs-all.js
[roojs1] / examples / grid / viewpanel.js
index ad223e3..0ec7212 100644 (file)
@@ -30,7 +30,7 @@ Roo.onReady(function(){
     // the data store (created below)
     var cm = new Roo.grid.ColumnModel([{
            header: "Common Name",
-           dataIndex: 'common',
+           dataIndex: 'url',
            width: 220  /*,
            
            editor: new Ed(new fm.TextField({
@@ -43,28 +43,24 @@ Roo.onReady(function(){
 
     // this could be inline, but we want to define the Plant record
     // type so we can add records dynamically
-    var Plant = Roo.data.Record.create([
-           // the "name" below matches the tag name to read, except "availDate"
-           // which is mapped to the tag "availability"
-           {name: 'common', type: 'string'},
-           {name: 'botanical', type: 'string'},
-           {name: 'light'},
-           {name: 'price', type: 'float'},             // automatic date conversions
-           {name: 'availDate', mapping: 'availability', type: 'date', dateFormat: 'm/d/Y'},
-           {name: 'indoor', type: 'bool'}
-      ]);
-
+    // 
     // create the Data Store
     var ds = new Roo.data.Store({
         // load using HTTP
-        proxy: new Roo.data.HttpProxy({url: 'plants.xml'}),
+        proxy: new Roo.data.HttpProxy({url: 'get-images.php'}),
         remoteSort : true,
         
         // the return will be XML, so lets set up a reader
-        reader: new Roo.data.XmlReader({
-               // records will have a "plant" tag
-               record: 'plant'
-           }, Plant)
+        reader: new Roo.data.JsonReader({
+            root: 'images',
+            totalProperty: 'totalCount',
+            id: 'id'
+        }, [
+            {name: 'name', type: 'string'},
+            {name: 'size', type: 'string'},
+            {name: 'lastmod', type: 'string'},
+            {name: 'url', type: 'string'}
+        ])
     });
 
     // create the editor grid
@@ -93,18 +89,9 @@ Roo.onReady(function(){
     
     var gridHead = grid.getView().getHeaderPanel(true);
     var tb = new Roo.Toolbar(gridHead, [{
-        text: 'Add Plant',
+        text: 'Add new',
         handler : function(){
-            var p = new Plant({
-                common: 'New Plant 1',
-                light: 'Mostly Shade',
-                price: 0,
-                availDate: new Date(),
-                indoor: false
-            });
-            grid.stopEditing();
-            ds.insert(0, p);
-            grid.startEditing(0, 0);
+            Roo.log('clicked');
         }
     }]);