3.2.0

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(calendar, date){
          if(calendar.dateClicked){
              editor.element().value = date; 
              calendar.callCloseHandler(); 
              editor.element().blur();
          }
      }
      
      var onClose = function(calendar){calendar.hide();calendar.destroy();}
      var cal = new Calendar(1, null, onSelect, onClose);
      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([calendar, text]);

document.write(table);
</script>


When i click in cell (first column), my event onFocus (declared in Template) never get called, why?

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

This topic is archived.

See also:


Back to support forum