Openui5 version working on: 1.38.4
wk_start_ts=new sap.m.DateTimeInput({type:"DateTime",
layoutData: new sap.ui.layout.GridData({linebreak: false,span: "L6 M6 S6"}),
dateValue: new Date(1468845873851),
valueFormat: "dd/MM/yyyy HH:mm:ss",
visible : true,
displayFormat: "dd/MM/yyyy HH:mm"}).placeAt("body");
var oButton1 = new sap.ui.commons.Button({
text : "Button",
tooltip : "This is a test tooltip",
press : function() {alert(wk_start_ts.getValue());}
});
oButton1.placeAt("body");
For example :
Expected data bound by default is 18/7/2016 18:56
Expected output is 18/7/2016 18:56
Actual Output : 07/18/2016 6:56 PM
Note: If I change value and then press button then I get expected date value.
Here is an example bin (https://jsbin.com/doxoro/edit?js,output).
Added a screenshot from browser tested upon i.e. Google Chrome
I debugged a bit and it appears that it processes the settings by for (property in settings) clause. So in your particular fragment dateValue is processed before any formatting options. And I would suggest to place dateValue at the end of the settings object:
wk_start_ts=new sap.m.DateTimeInput({type:"DateTime",
layoutData: new sap.ui.layout.GridData({linebreak: false,span: "L6 M6 S6"}),
valueFormat: "dd/MM/yyyy HH:mm:ss",
visible : true,
displayFormat: "dd/MM/yyyy HH:mm",
dateValue: new Date(1468845873851)
}).placeAt("body");
var oButton1 = new sap.ui.commons.Button({
text : "Button",
tooltip : "This is a test tooltip",
press : function() {alert(wk_start_ts.getValue());}
});
oButton1.placeAt("body");
Related
I realize a site in symfony and I use the flatpickr library for the selection of dates. that's what it's like now:
datepicker
So I have 2 datepicker who uses flatpickr which allows me to select a departure date with the time and a date back with the time too. My problem, when I select the first date, flatpickr shows me well the time selection but when I go on the second datepicker I can not select the time.
datepicker 1
datepicker 2
I wish I could select in the 2 inputs the date and the time.
Here is my JS code of my 2 inputs:
var departure = $('#quick_booking_departure');
var arrival = $('#quick_booking_arrival');
departure.flatpickr({
enableTime: true,
dateFormat: "Y-m-d H:i",
position: "above",
disableMobile: true,
locale: "fr",
minDate: "today",
onChange: function (selectedDates, dateStr, instance) {
arrival.flatpickr({
minDate: dateStr
});
departure.removeAttr('readonly');
arrival.removeAttr('readonly');
}
});
arrival.flatpickr({
enableTime: true,
dateFormat: "Y-m-d H:i",
position: "above",
disableMobile: true,
locale: "fr",
minDate: "today",
onChange: function (selectedDates, dateStr, instance) {
departure.flatpickr({
minDate: 'today'
});
departure.removeAttr('readonly');
arrival.removeAttr('readonly');
}
});
Thank you for your help.
It looks like your onChange function is the culprit adding enableTime: true allows time pick:
onChange: function(selectedDates, dateStr, instance) {
arrival.flatpickr({
enableTime: true,
minDate: dateStr
});
departure.removeAttr('readonly');
arrival.removeAttr('readonly');
}
But look closer, when one of your pickers change you are completely re-initializing the other. So all the options you originally defined are getting reverted back to default except for what you are re-defining minDate
The following code was working with Smartface 4.2.4 but the same code crashes for Smartface 4.3. Did something change in the new version?
function Page1_ImageButton3_OnTouch(e){
showDate();
}
function showDate(){ SMF.UI.showDatePicker({
CurrentDate : new Date(), // date is given with JS date object
mask : "YYYY-MM-DD",
minDate:new Date("2000-01-01"),
maxDate:new Date("2030-12-01"),
showWorkingDate : true,
onSelect : function(e) {
alert("Working!")
}
});
}
Why did you set 2030 on maxDate?
Anyway, you have missed and write wrong some properties of datepicker object. You can try this it will work iOS and Android:
SMF.UI.showDatePicker({
mask : "yyyy-MM-dd",
currentDate : new Date(),
minDate : new Date("2000-01-01"),
maxDate : new Date("2030-12-01"),
showWorkingDate : true,
displayMode : 2,
onSelect : function (e) {},
onCancel : function (e) {}
});
I'm really just looking to assign additional information to dates. I am currently setting up datepicker with the following:
beforeShowDay: function(date){
dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
if ($.inArray(dmy, ajaxDates) != -1) {
return [true, "","Available"];
} else {
return [false,"","unAvailable"];
}
},
Where ajaxDates is an array containing a list of available dates such as:
var ajaxDates = [ "26-2-2015", "27-2-2015"];
It's for a booking system were I have another array containing the number of seats available for every date. I had seen a post that I can no longer find were someone was attaching additional information to the dates. If someone could point me in the right direction that would be great!
Edit: I have noticed that the a title is attached to each date which on hover shows the tooltip as "Available" or "Unavailable". Is there any easy method to access through the datepicker?
The solution that I was referring to was:
Add custom parameter to jQuery UI Datepicker
An example of how to set additional parameters is as followed:
var input = $("#datepicker");
var result = $("#result");
var courses = {
"02-09-2013" : "history",
"10-09-2013": "physics"
};
input.datepicker({
dateFormat: 'dd-mm-yy',
showWeek: true,
firstDay: 1,
numberOfMonths: 3,
onSelect: function(dateText, pickerObj){
result.attr("data-course-id", courses[dateText]);
course.innerHTML = courses[dateText];
},
altField: "#result"
});
http://jsfiddle.net/Seandeburca/qbLwD/
How to assign a button with picture for a datepicker defined on smartface?
When an icon assigned on datepcker structure it adds "select date.." text instead of image as button.
You can create a imageButton to call showDatePicker method with images.
For example;
function showDate(){
SMF.UI.showDatePicker({
currentDate : (new Date()).toString(), // date is given with JS date object
mask : "dd-MM-yyyy",
minDate : new Date("13 October, 2013"),
maxDate : new Date("13 October, 2020"),
showWorkingDate : true,
onSelect : function (e) {
var sDate = new Date(e.date);
alert("Selected date: " + sDate.toString());
},
onCancel : function (e) {
alert("Picker cancelled!");
}
});
}
var imageButton1 = new SMF.UI.ImageButton({
width : "9.38%",
height : "10.38%",
left : "5%",
top : "84.62%",
touchEnabled : false,
imageFillType : SMF.UI.ImageFillType.autosize,
defaultImage : "datePicker.png", //which is your date icon
highLightedImage : "content1.png", //which is your date icon when highligted
inactiveImage : "content2.png", //which is your inactive date icon
text : "",
onPressed : showDate,
});
I have a page in which I have a date field and a CKeditor textarea(which creates an iframe at the textarea place) . On date picker I have defined a blur function to check date validity, which works correctly.
However, the issue is when I click on a datepicker field the calendar popup gets generated then I enter a invalid date and then click on inside ckeditor , the calendar remains open however focus gets lost but still the blur function doesn't get called. Hence invalid date goes to server. (I need client side validation for this date field) .
$(function(){
$(".dateClass").datepicker({
changeMonth : true,
changeYear : true,
yearRange: "-10:+10",
dateFormat : "dd/mm/yy",
buttonText : "Choose",
showOtherMonths : true,
selectOtherMonths : true
});
$(".dateClass").blur(function(){
if(this.value!=undefined && this.value!=null && this.value.replace(/^\s+|\s+$/g, '')!=''){
if(!isDateValid(this.value) && calendarOpen==0){
alert('Please enter a valid date in dd/mm/yyyy format');
this.focus();
}
}
});
});
CKeditor is actually embedding an iframe in the page.
How do I call blur function when user clicks on date field and then on iframe ??
thnx I got it to work by doing a way around
document.onfocusout = function(e){ //for IE8 and lesser
if( e === undefined ){
//keeping validations here
}
}
$(window).blur( function(e){ //for other browsers –
if( e !== undefined ){
//keeping validations here
}
}
Use onSelect for your required situation as
$(".dateClass").datepicker({
changeMonth : true, changeYear : true,
yearRange: "-10:+10", dateFormat : "dd/mm/yy",
buttonText : "Choose", showOtherMonths : true,
selectOtherMonths : true ,
onSelect: function(dateText, inst) { var date = $(this).val(); var time = $('#time').val(); alert('on select triggered');
}
});
Sorry for unformated code.
Hope it will help
http://forum.jquery.com/topic/jquery-datepicker-onblur