Show Jquery Date time picker onclick - javascript

I am using a ASP.NET GRIDVIEW. The column I am interested in is the "CHECKED IN" column that contains a checkbox and a label.
Grid View Image
The grid can bring back many lines of data from the database:
Columns of grid
Here's what I need to do:
When the 'Checked IN' checkbox is clicked. I would like the DataTime picker to appear.
[Checkbox is checked and Datatime picker appears][3]
checked in Checkbox
2. When the user has selected a date and time, I would like the value to appear in the label next to the Checked in checkbox.
DateTime to show only when it has been selected.
[Label is updated][4]
Hope this makes sense?
The only issue is that the GridView creates itself dynamically.

Thanks for your message.
I did resolve this, however I slightly changed what I was doing.
Here's my code...
$(".CheckOut").each(function () {
$(this).datetimepicker({
dateFormat: 'dd/mm/yy',
onClose: function (selectedDateTime) {
return Validate(this, this.id);
}
});
});
This code is exactly what I needed for the date/time picker to work within a GridView.

Related

Setting selected date in calendar to null on Bootstrap datetime picker

I'm using the bootstrap datetime picker, the documentation of which can be found here: https://eonasdan.github.io/bootstrap-datetimepicker/Options/
I'm trying to set the selected date to null. I'm able to blank out the date (i.e. 2/10/2019) within the input field, but when I click on the input field and the calendar opens, the old date is still selected in blue. WiThis is my code to de-select all dates within the calendar.
$(document).ready(function() {
$('.removedate').on('click', function(){
$("#id_booking_date").val('') //this correctly removes date from input field
$('.input-group').datetimepicker({
date: new Date(null)
});
});
This code isn't working. Do you know what I should try?
Thanks!
Can you please try to use "useCurrent" option for this? Check it out here https://eonasdan.github.io/bootstrap-datetimepicker/Options/#usecurrent
Please try this, they have clearly mentioned here
Working example:
$('#datetimepicker4').datetimepicker({
useCurrent: false,//
});

FullCalendar - changeView not resetting onclick

I am trying to change the view of a calendar, and show a specific date range, based on some fields content.
The date format from inside these 2 fields are like this : 2018-05-05
Here's my code:
$('#checkRange').on('click', function () {
$('#calendar').fullCalendar('changeView', 'list', {
start: $('#firstDate').val(),
end: $('#endDate').val()
});
});
So basically, when I click on the "checkRange" button, I want the calendar to switch the view to the list view, and change the "start" and "end" options to the value inside the "firstDate" field, and "endDate" field.
It works fine the first time the page loads, but it looks like once the "start" and "end" options are set, even if I change the content of the "firstDate" and "endDate" fields, and click the "checkRange" button again, it will not update the view.
Any help would be highly appreciated.
Thanks!
Try this: https://fullcalendar.io/docs/v1/rerenderEvents
$("selector").fullCalendar( ‘rerenderEvents’ );
or https://fullcalendar.io/docs/v1/refetchEvents
$("selector").fullCalendar( ‘refetchEvents’ );

Bootstrap datetimepicker automatically populates date

When I click on datetimepicker current date automatically gets populated in input field. I want that it should populate only when I select a date in popup box. Is there any flag to do it ?
$('#datetimepickerStartDate').datetimepicker({
format: 'DD-MMM-YYYY'
});
Ok. I got the solution. It can be done by setting "useCurrent" to false.
Setting the useCurrent option to false will disable this functionality:
$('#datetimepickerStartDate').datetimepicker({
useCurrent: false
});

Update bootstrap datetimepicker after every step/click

I'm using this extension of Bootstrap's datepicker. It works well enough, but I've come upon a usability issue - when selecting a date/time, the text field the datepicker is attached to does not update unless all the steps (year/month/day/hour/minute) are selected to the end. Clicking away from the datepicker before clicking all the steps yields no change to the date in the text field.
How do I make it so that when the user clicks away mid-selection (maybe because they just want to change the date, but find the already-present hour and minute to be acceptable), the text field is updated appropriately?
For example:
Initial date in field: 2015/10/10 10:00
Click on 2015/10/15 -> click away -> date in field: 2015/10/15 10:00
Is that even possible?
Check this updated fiddle - https://jsfiddle.net/4cqLcxcm/8/
Added on changeDay event on datepicker, which will trigger on change of date and set that value into input box.
Below is the code I have changed.
$(document).ready(function() {
var now = new Date();
$('#send-time').datetimepicker({
format: 'yyyy/mm/dd hh:ii',
startDate: now
})
.on('changeDay', function(ev){
$('#send-time').datetimepicker('update',ev.date);
});
console.log('test');
});

jQuery clear the value from the datepicker field, tied to the checkbox being unchecked

Here is my scenario:
I have a form, with a checkbox.
- When it is checked, I hide another <div> that has a termination date input field, which has a datepicker.
- When the checkbox is not checked, I want to display the the <div> with termination date field. User, clicks on the date, and selects one.
The problem I can't figure out: if after selecting the date, the user checks again the checkbox, how to reset the termination date field to nothing?
I placed the code on jsfiddle.
I already tried what seems like a million ways of doing it, and nothing seems to be working.
Any help with this, is greatly appreciated!!!
I gave it a shot:
http://jsfiddle.net/z8gEy/16/
I simply added after the hide method:
$("input[type=date][name$=TerminationDate]").val('');
var hdnFromDate = document.getElementById('FromDate').value;
if (hdnFromDate == '') {
var picker = new Pikaday({
field: document.getElementById('FromDate'),
toString(date, format) { // using moment
return moment(date).format('DD/MM/YYYY');
// return moment(date).format('YYYY/MM/DD');
},
});
}

Categories