Roo/grid/Calendar.js
[roojs1] / Roo / grid / Calendar.js
index a827920..1c6211e 100644 (file)
@@ -6,7 +6,7 @@
  
 /**
  * @class Roo.grid.Calendar
- * @extends Roo.util.Grid
+ * @extends Roo.grid.Grid
  * This class extends the Grid to provide a calendar widget
  * <br><br>Usage:<pre><code>
  var grid = new Roo.grid.Calendar("my-container-id", {
@@ -779,21 +779,35 @@ Roo.extend(Roo.grid.Calendar, Roo.grid.Grid, {
         });
         
         this.eventStore.each(function(e) {
-            Roo.each(e.els, function(el) {
+            this.clearEvent(e);
+        },this);
+        
+    },
+    
+    clearEvent : function(ev)
+    {
+        if (ev.els) {
+            Roo.each(ev.els, function(el) {
                 el.un('mouseenter' ,this.onEventEnter, this);
                 el.un('mouseleave' ,this.onEventLeave, this);
                 el.remove();
             },this);
-            e.els = [];
-        },this);
-        
+            ev.els = [];
+        }
     },
     
     
-    function renderEvent(args,ctr) {
+    renderEvent : function(ev,ctr) {
         if (!ctr) {
              ctr = this.view.el.select('.fc-event-container',true).first();
         }
+        
+         
+        this.clearEvent(ev);
+            //code
+       
+        
+        
         ev.els = [];
         var cells = ev.cells;
         var rows = ev.rows;
@@ -809,7 +823,7 @@ Roo.extend(Roo.grid.Calendar, Roo.grid.Grid, {
                 cls += ' fc-event-end';
             }
             
-            Roo.log(ev.data);
+            //Roo.log(ev.data);
             // how many rows should it span..
             var cg = this.eventTmpl.append(ctr,Roo.apply({
                 fccls : cls
@@ -830,7 +844,7 @@ Roo.extend(Roo.grid.Calendar, Roo.grid.Grid, {
             cg.setXY([sbox.x +2, sbox.y +(ev.row * 20)]);    
             cg.setWidth(ebox.right - sbox.x -2);
         }
-    }
+    },
     
     renderEvents: function()
     {   
@@ -852,7 +866,7 @@ Roo.extend(Roo.grid.Calendar, Roo.grid.Grid, {
         
         
         this.cells.each(function(c) {
-            Roo.log(c.select('.fc-day-content div',true).first());
+            //Roo.log(c.select('.fc-day-content div',true).first());
             c.select('.fc-day-content div',true).first().setHeight(Math.max(34, (c.rows || 1) * 20));
         });
         
@@ -862,45 +876,8 @@ Roo.extend(Roo.grid.Calendar, Roo.grid.Grid, {
         this.eventStore.each(function(ev){
             
             this.renderEvent(ev);
-            
-            ev.els = [];
-            var cells = ev.cells;
-            var rows = ev.rows;
-            this.fireEvent('eventrender', this, ev);
-            
-            for(var i =0; i < rows.length; i++) {
-                
-                cls = '';
-                if (i == 0) {
-                    cls += ' fc-event-start';
-                }
-                if ((i+1) == rows.length) {
-                    cls += ' fc-event-end';
-                }
-                
-                Roo.log(ev.data);
-                // how many rows should it span..
-                var cg = this.eventTmpl.append(ctr,Roo.apply({
-                    fccls : cls
-                    
-                }, ev.data) , true);
-                
-                
-                cg.on('mouseenter' ,this.onEventEnter, this, ev);
-                cg.on('mouseleave' ,this.onEventLeave, this, ev);
-                cg.on('click', this.onEventClick, this, ev);
-                
-                ev.els.push(cg);
-                
-                var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
-                var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
-                //Roo.log(cg);
-                 
-                cg.setXY([sbox.x +2, sbox.y +(ev.row * 20)]);    
-                cg.setWidth(ebox.right - sbox.x -2);
-            }
-            
-            
+             
+             
         }, this);
         this.view.layout();