EasyUI Forum

General Category => General Discussion => Topic started by: korenanzo on September 25, 2017, 09:11:12 AM



Title: closing datetimebox
Post by: korenanzo on September 25, 2017, 09:11:12 AM
Hi,

in a datetimebox , when  clicking a calendar date I need the same behaviour of OK button, that is: selecting the new date and time,move it in the textbox and close the calendar: how can I do this?

THanks ,ric


Title: Re: closing datetimebox
Post by: stworthy on September 25, 2017, 05:13:16 PM
Please try this code:
Code:
var dt = $('#dt');
dt.datetimebox({});
var c = dt.datetimebox('calendar');
var t = dt.datetimebox('spinner');
c.calendar({
onSelect: function(date){
setValue();
}
})
t.timespinner({
onChange: function(value){
setValue();
}
})
function setValue(){
var date = c.calendar('options').current;
date = new Date(date.getFullYear(), date.getMonth(), date.getDate(), t.timespinner('getHours'), t.timespinner('getMinutes'), t.timespinner('getSeconds'));
var val = dt.datetimebox('options').formatter.call(dt[0],date);
dt.datetimebox('setValue', val);
}


Title: Re: closing datetimebox
Post by: rannacher on January 25, 2019, 05:30:58 PM
Hello,

I have exactly the same problem, but dont understand where to put this code.

Cannot be onSelect/onChange in datetimebox data-options as there I dont get the time, only date.
And if I just put outside afterwards in normal script tag then it does not work either.

I simply dont get the time when clicking on the datetimebox calendar and it also does not closed as wanted after the click.

Help appreciated very much and thx in advance !!!

BR Michael.