Kendo UI Calendar - clears past dates when calendar icon clicked - date

In my screen the Kendo UI Calendar used behaves odd.
When i come on to editing the screen and click on Calendar field if the date is past date (disabled on calendar) then the existing date value gets cleared, even though i am not making any change.
How can i persist the date value for the past dates that are disabled in the calendar.
It would be helpful to give sample code for the fix.
The same we tried with HTML calendar and JQuery Calendar and the behavior is same as of Kendo UI Calendar.
The code used is in javascript
$('#txtWFITaskStartDate').change(function (e) {
e.preventDefault();
e.stopImmediatePropagation();
var labelName = $(this).data('validatelabel');
var CurrentId = $(this).attr('id');
var startDate = $("#" + CurrentId).val();
var duration = $('#txtWFITaskDuration').val();
if ($('#' + CurrentId).val() === "") {
varErrorClassName = 'errmsgStartDate';
DisableTaskEditControls();
$('#StartDate').after('<span class="text-danger ' + varErrorClassName + '">' + Web_IsRequired.replace("{0}", labelName) + '</span>');
}
else {
$('.errmsgStartDate').remove();
$('.errmsgEndDate').remove();
EnableTaskEditControls();
var endDate = CalculateEndDate(duration, startDate);
$('#txtWFITaskEndDate').val(endDate);
$('#EndDate').datepicker('setDate', new Date(endDate));
endDate = $('#txtWFITaskEndDate').val();
if (endDate !== "") {
EnableTaskEditControls();
} else {
varErrorClassName = 'errmsgEndDate';
$('#EndDate').after('<span class="text-danger ' + varErrorClassName + '">' + Web_IsRequired.replace("{0}", "End date") + '</span>');
DisableTaskEditControls();
}
}
});
Below is the screenshot of the dates displayed on modal popup view (MVC)
As the Start Date is past date the control displays in disabled mode. When focus to the Start Date control and focus out from it. The past date gets cleared. I want to hold the existing value, until user changes the date else the same value has to persist in the Start date text box.

Related

Make TODAY formula stop when checkbox is clicked

I'm setting up a Google Sheet with a few columns to be filled for a certain request. So, I included a checkbox to be clicked at the end as a confirmation the request is done. My idea is to have an automated column called 'Request Date' automatically filled with the current date as soon as the Confirmation checkbox is clicked. However, can't use TODAY() formula once it's going to change the date every day. Any solution for this?
unfortunately no. you can't stop TODAY on demand by any means without a script. but you could have a script which would print out the date if certain checkboxes were checked.
function onEdit(e) {
var aCell = e.source.getActiveCell(), col = aCell.getColumn();
if(col == 5) { //number of column where you have a checkbox
var adjacentCell = aCell.offset(0,1);
var newDate = Utilities.formatDate(new Date(),
"GMT+1", "dd/MM/yyyy");
adjacentCell.setValue(newDate);
}}
this will print date in column F if a checkbox in column E is checked
or perhaps like this:
function onEdit(e) {
var activeSheet = e.source.getActiveSheet();
if (activeSheet.getName() == "Sheet1") { // SHEET NAME
var aCell = e.source.getActiveCell(), col = aCell.getColumn();
if (col == 12) { // COLUMN WITH CHECKBOXES
var dateCell = aCell.offset(0,1); // OFFSET ROWS, COLUMNS
if (aCell.getValue() === true) { // VALUE OF CHECKED CHECKBOX
var newDate = new Date();
dateCell.setValue(newDate);
} else {
dateCell.setValue("");
}}}}

How To Disable Specific Days and Dates Using BeforeShowDay In jQueryUiDatepicker?

I already have functioning code in jQueryUiDatepicker that disables Fridays and Saturdays and all previous days (plus 2 days). My issue is trying to add 2 specific dates to this existing Datepicker code that will also disable these dates.
This is my existing code on starting line 92 in jQueryUiDatepicker:
beforeShowDay: function(date) {
var show = true;
if(date.getDay()==5||date.getDay()==6) show=false
return [show];
},
beforeShow: function(){
var dateTime = new Date();
var hour = dateTime.getHours();
//If Hour is greater or equals to 8AM
if(hour >= 08){
//Disable all past days including tomorrow and today
$(this).datepicker( "option", "minDate", "+2" );
}
},
I am trying to disable 18th and 19th October 2017 and failing, this is the code I have added directly underneath the above code:
beforeShowDay: var array = ['18/10/2017', '19/10/2017']
$('input').datepicker({
beforeShowDay: function(date){
var string = jQuery.datepicker.formatDate('dd/mm/yy', date);
return [ array.indexOf(string) == -1 ]
},
My question is how can I disable all previous dates, all Fridays and Saturdays and these 2 dates in the October?
Note# This coding has to be done in jquery.ui.datepicker, not a script in html
Hope this helps
use inArray instead of indexOf and you can also disable all previous dates using minDate
var array = ["18/10/2017", "19/10/2017"];
$(function() {
$('input').datepicker({
minDate: new Date(),
beforeShowDay: function (date) {
$thisDate = date.getDate() + "/" + (date.getMonth() + 1) + "/" + date.getFullYear();
var day = date.getDay();
if ($.inArray($thisDate, array) == -1&&day!=5&&day!=6) {
return [true, ""];
} else {
return [false, "", "Unavailable"];
}
}
});
});
DEMO

Calendar input for dat.gui

Is there any way to have a Calendar input for dat.GUI? I'd like to be able to use the UI to input dates if possible. My work around is currently to enter the dates as Text, but I would prefer to have some type of calendar. Thanks!
I know the question was asked sometime ago, but it hasn't been answered yet. Out of a similar need, I created this codepen that demonstrates the integration of jquery-simple-datetimepicker with dat.GUI. The pertinent section/logic follows:
$(function(){
//Create dat.gui instance
var gui = new dat.GUI({closeOnTop: true, width:450});
var calendarFolder = gui.addFolder("Calendar");
//Add calendarDate to dat.GUI
var dateController = calendarFolder.add({Date: ""}, "Date");
calendarFolder.open();
//Append Date Picker to calendarDate and show it.
var guiInput = $(calendarFolder.domElement).find("input").eq(0);
//Create event handler to update the dat.GUI input element when calendar is hidden
var datePickerOptions = {"onHide": function(handler){ fnSetGuiDate(); } };
//Add the calendar to the dat.GUI input element and immediately show it for demonstration
guiInput.appendDtpicker(datePickerOptions).handleDtpicker('show');
//Initialize the dat.GUI input value
fnSetGuiDate();
function fnSetGuiDate() {
var date = guiInput.handleDtpicker('getDate');
var strDate = date.getFullYear() + "-" +
fnFormat(date.getMonth() + 1) + "-" +
fnFormat(date.getDate()) + " " +
fnFormat(date.getHours()) + ":" +
fnFormat(date.getMinutes());
dateController.setValue(strDate);
function fnFormat(mnthOrDate) {
return mnthOrDate < 10 ? "0" + mnthOrDate : mnthOrDate;
}
}
});

SAPUI5 DatePicker / DateRangePicker. Min + Max dates

I can set the dateValue attribute in the Date Pickers, but unfortunately the user can still enter a date before it.
Is there any way I can set an minimum (and maximum) date on the datepicker?
Regards
Adam
Unfortunately until the current Version 1.36 of SAPUI5 the control sap.ui.commons.DatePicker does not provide such functionalities. But you still can handle this yourself with the change event.
var minDate = "12121991";
var maxDate = "12122020";
var oDatePicker = new sap.ui.commons.DatePicker();
oDatePicker .attachChange(function(oEvent) {
if(oEvent.getParameter("invalidValue") || this.getYyyymmdd() < minDate || this.getYyyymmdd() > maxDate) {
oEvent.oSource.setValueState(sap.ui.core.ValueState.Error);
} else{
oEvent.oSource.setValueState(sap.ui.core.ValueState.None);
}
});

jQuery Datepicker popup tooltip

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/