Login Register

DateTime widget

Hi to all,
I'm trying to write a DateTime widget. I'm almost done but I've a kind of cosmetic bug I cannot bypass.
The two input for Date and Time are rendered, but they not respond to the first click. I have to click on one (i.e. Time), than click on Date and the calendar displays. Plus, some times when I click on Date the calendar pop ups, but even an empty time selector pop ups.
Here is the template I'm using:

<table class="dijit  dijitInlineTable"
       cellspacing="0" cellpadding="0"
       waiRole="presentation"
       id="widget_${id}">

  <tbody>
    <tr>
      <td class="required_${required}">
        <span dojoAttachPoint="labelNode">${label}</span>
        <input type="text"
               id="${id}_date"
               dojoType="dijit.form.DateTextBox"
               dojoAttachPoint="dateNode"
               required="${required}"
               constraints="{selector: 'date'}"
               style="width: 12em;">

       
        <input type="text"
               id="${id}_time"
               dojoType="dijit.form.TimeTextBox"
               dojoAttachPoint="timeNode"
               required="${required}"
               constraints="{selector: 'time'}"
               style="width: 12em;">


        <input type="text"
               name="${name}"
               dojoAttachPoint="myTextbox, textbox"
               style="display: none">

      </td>
    </tr>
  </tbody>
</table>

and here is the .js:

dojo.provide("dojoc.widget.DateTime");
dojo.require("dijit._Widget");
dojo.require("dijit.form.DateTextBox");
dojo.require("dijit.form.TimeTextBox");
dojo.require("dijit._Templated");
ojo.declare("dojoc.widget.DateTime", [ dijit._Templated, dijit.form.DateTextBox, dijit.form.TimeTextBox ], {
  id: 'dt',
      name: 'dt',
      label: 'Label',
      required: 'true',
      value: dojo.date.locale.format(new Date(),
                                     { timePattern:"HH:mm", datePattern:"yyyy/MM/dd"}),
      templatePath: dojo.moduleUrl("dojoc.widget","DateTime/DateTime.html"),
      templateString: "",
      src: "",
      widgetsInTemplate: true,
     
      startup: function() {
      console.debug("Startup start");
      this.setValue(this.value);
      console.debug("Startup stop");
    },
      postMixInProperties: function() {
      console.debug("postMixInProperties start");
      this.inherited("postMixInProperties",arguments);
      console.debug("postMixInProperties stop");
    },
      postCreate: function() {
      console.debug("postCreate start");
      this.timeNode.postCreate(arguments);
      this.dateNode.postCreate(arguments);
      console.debug("postCreate stop");
    },
      getValue: function() {
      var timeVal=dojo.date.locale.format(this.timeNode.getValue(), { selector: 'time', timePattern: 'HH:mm'});
      var dateVal=dojo.date.locale.format(this.dateNode.getValue(), { selector:'date', datePattern: 'yyyy-MM-dd'});
      return dateVal+"T"+timeVal;
    },
      setValue: function(val, options) {
      var date=new Date(val);
      this.timeNode.setValue(date);
      this.dateNode.setValue(date);
    },
      toString: function(val, options) {
      var dateVal=dojo.date.locale.format(val, {selector:'date', datePattern: 'yyyy-MM-dd'});
      var timeVal=dojo.date.locale.format(val, {selector:'time', timePattern: 'HH:mm'});
      return dateVal+"T"+timeVal;
    },
      updateValue: function() {
      var valueNode = this.myTextbox;
      valueNode.setAttribute("value", this.getValue());
    },
      isValid: function() {
      this.updateValue();
      return true;
    },
  }
  );

Can anyone help me?
TIA

try setting _open

The DateTextBox and TimeTextBox both call _open in dijit.form._DateTimeTextBox to open their date pickers up on a click, so I'd try over-riding that in your js and calling it for each of your mixed in widgets.

That's just a guess though, I haven't tested it or looked into it too deeply.

HTH.

Thanks, you were right

I've overwitten _open and _close and solved the cosmetic bugs.
Now I'm trying to have an onChange method in my widget, with no sucess up to now

--
Andre

Did you get this to work completely?

If so, can you share the completed code?

Thanks

removed

Solved above