:: Forum >> Version 2 >>

Upgrading Calendar Template to v2.0 aw

Guys... i found a rulez calendar template working wonderfull in aw version 1.0, now i want modify to 2.0.

I dont know whats is wrong... my code down:

template
// ****************************************************************
//     Calendar Cell Template.
// ****************************************************************
Sonner.Templates.Calendar AW.Templates.Text.subclass();

Sonner.Templates.Calendar.create = function()
{
  var 
obj this.prototype;

  
// editor is not part of the template,
  // there is only one single instance of editor object.
  
var editor = new AW.UI.Input;
  
editor.setClass("templates""input");
  
editor.setAttribute("type""text");
  
editor.setAttribute("value", function(){
      return 
template.getItemProperty("text");
  });

  
// template variable provides temporary reference
  // to the parent template during edit mode.
  
var template;

  function 
switchToEditMode(){
      if (
template) {
          
switchToTextMode()
      }
      
      
template this;
      
template.element().style.padding 0;
      
template.element().innerHTML editor;
      
editor.element().focus();
      
// pop-up calendar now
      
var onSelect = function(calendardate){
          if(
calendar.dateClicked){
              
editor.element().value date
              
calendar.callCloseHandler(); 
              
editor.element().blur();
          }
      }
      
      var 
onClose = function(calendar){calendar.hide();calendar.destroy();}
      var 
cal = new Calendar(1nullonSelectonClose);
      
cal.weekNumbers false;
      
cal.setDateFormat("%m/%d/%Y");
      
cal.create();
      
cal.parseDate(editor.element().value);
      
cal.showAtElement(editor.element());
  }

  
obj.setEvent("onfocus"switchToEditMode);

  function 
switchToTextMode(){
      var 
originalVal template.getItemProperty("text");
      var 
value editor.element().value;
      if(
originalVal != value){
          
template.setItemProperty("text"value);
          
//dumpElement(template);
      
}
      
template.refresh();
      
template null;
  }

  
editor.setEvent("onblur"switchToTextMode);
};

Sonner.Templates.Calendar.create(); 

 
JSP

...
<
script>
var 
records = [ ["10/05/2002""10 de Maio de 2002"],
                [
"28/07/2001""28 de Julho de 2001"],
                [
"17/11/2006""17 de Novembro de 2006"],
                [
"15/02/2003""15 de Fevereiro de 2002"],
                [
"08/09/2004""08 de Agosto de 2004"]
];
var 
columns = [ "Data""Data Escrita" ];
             
var 
table = new AW.UI.Grid;
table.setHeaderText(columns);
table.setColumnCount(2);
table.setRowCount(5);
table.setCellText(records);

// templates
var calendar = new Sonner.Templates.Calendar;
var 
text     = new AW.Formats.String;
table.setCellFormat([calendartext]);

document.write(table);
</
script>
 
When i click in cell (first column), my event onFocus (declared in Template) never get called, why?

tkz.
pc
Wednesday, April 5, 2006
nvm, i got the solution.
my mistake, cellFormat != cellTemplate
tkz.
pc
Tuesday, April 11, 2006



This topic is archived.

Back to support forum

Forum search