Dojo date text box in custom widget

1170
4
03-01-2017 01:48 AM
JonathanKnowles1
New Contributor III

Hi

Anyone had any luck adding a dojo date text box to a Web App Builder widget ?

I have a project coming up and i was just wondering if anyone had successfully used it.

Thanks
Jonathan

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Jonathan,

 

  I have done it many time. Are you have a problem with your code?

0 Kudos
JonathanKnowles1
New Contributor III

Hi Robert

I have created a date text box with the following;

new OracleDateTextBox({
value: this._getDate('today'),
name: "calTo",
style: { width: '140px' },
onChange: lang.hitch(this, function(v){ setTimeout(this.showServerValue('to'), 0)}),
constraints: { datePattern : 'dd/MM/yyyy' },
}, this.calTo).startup();

Html in widget;

From:<input data-dojo-attach-point="calFrom" />

I am struggling with the syntax to set the value in the calendar;

setDateByHours: function(e){
var today = new Date();
var todayReal = new Date();
console.log(e.target.id);
switch (e.target.id) {
case '24':
today.setDate(today.getDate() - 1);
break;
case '48':
today.setDate(today.getDate() - 2);
break;
case '4Days':
today.setDate(today.getDate() - 4);
break;
case '7Days':
today.setDate(today.getDate() - 7);//d.setMonth(d.getMonth() - 3);
break;
case 'month':
today.setMonth(today.getMonth() - 1);
break;
}
dijit.byId('calFrom').attr("value", today);
dijit.byId('calTo').attr("value", todayReal);
},

Any ideas what I am doing wrong ??

Thanks

Jonathan

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Jonathan,

   I have never heard of a OracleDateTextBox or worked with it. Is there a reason you do not just use the standard dijit/form/DateTextBox?

0 Kudos
JonathanKnowles1
New Contributor III

Hi

I managed to fix it in the end, by adding an id to the html in widget.html

The data we are accessing has time enabled, so I decided to use the OracleDateTextBox example off dojo`s website.

Thanks

Jonathan

0 Kudos