Angular Material Datepicker Highlight Range Week Start to Week End - javascript

I need users to pick a beginning week and an ending week since the data being returned in a range of start week to end week.
I am attempting to highlight the entire week on any date picked on start date range and highlight the entire end week selecting the last day in the end week.
I am using a date range picker and the highlight works fine and inputs the start day of the week and the last day in the end week... but i cant understand how to highlight it in the picker. Instead, the picker shows the mid week day a the start of the selected dates not the beginning day of thee week/
I want my users to select a start and end week.
I have created a dateClass and a method but i am unable to set the week range to a color.
Reproduction
Here's the stackblitz:
https://stackblitz.com/edit/angular-ucvaay?file=src/app/date-range-picker-overview-example.html
Steps to reproduce:
Click the calendar - click a date that is not a weekend or the beginning day of the week
the input will update the value to the beginning day of the week and when an end day is selected it will get the last day in the end date week (as expected)
The issue: Open the datepicker again and notice that highlighted date range does not include the beginning days (entire week highlighted nor the end week highlighted.
I need users to pick a beginning week and an ending week since the data being returned in a range of start week to end week.
Any idea on how to get the start and end week to select like the range selection?

You can add a FormGroup to your datepicker which gives you the ability to change the values of the start and end date. In your dateRangeChange()-method you could then update the selected values to the beginning and end of the week. I added the functionality to your Stackblitz-project: https://stackblitz.com/edit/angular-ucvaay-8brpty?file=src/app/date-range-picker-overview-example.ts

Related

How to select whole week on date picker angular material?

I want to select whole week on date picker with highligted on calander and want to choose first date of a week as values.
Eg if I select thursday select or highlight whole week from monday to sunday and restrict to overlap dates .
here is sample image
See the stackblitz link with the answer to your question.
Stackblitz Example

preventing Date-picker from auto-select a date

I am using and readonly datepicker (bootstrap) with disabled weekends and public holidays. When selecting a month/ year however it always selects the first day of the month or year and only moves on to the date selection if this first day is an invalid. The datepicker modal opens initially with the current day (which is also an invalid day ..on purpose) so it let me select an day but ones i go to month or even years before selecting a day of the current month, it populates it with the default of the first day of the month/year. is there a way to prevent this from happing and only updates the date ones day, month and year has been selected by the user.
Use setDate method you can clear input field state this way:
$("#datepicker").datepicker();
$("#datepicker").datepicker('setDate', null);
Try this code:
$('#datepicker').val('').datepicker('update');
Or
$('.datepicker').datepicker('update', '');
Source

jQuery calendar with month and yearly view, I want to show 10th of every month in the calendar

jQuery calendar with month and yearly view, I want to show 10th of every month in the calendar If 10th falls on a holiday then show the next working day.
please refer to the image for more detail

Restrict and change select lists values used along jQuery UI's datepicker

I'm using jQuery UI's datepicker to display a calendar with select lists. Input field and select list are synchronized, so when you change value of either the datepicker or select list, the value of the other fields will change accordingly.
The datepicker is used with the Restrict date range functionality (http://jqueryui.com/datepicker/#min-max). That does its job perfectly - the END date can't be before the START date and you are unable to choose previous days accordingly. Of course, you can't choose that the START date is after the END date either.
The problem is with the select list. Even if "restrict date range" does its job, you still can select any date with the select lists. Therefore, I'm looking for this solution when you use the select lists (it shouldn't affect anything if you only use the calendar icon):
If you first select the START date, the END date should automatically change to one day after the selected date.
If you have both dates selected and decide to change the START date to the date that is after the END date, the END date should again change to one day later.
If you have both dates selected and decide to change the END date to the date that is before the START date, the START date should change to one day before the END date.
I have tried with using this piece of code to affect #1 and #2:
$('#start').change(function() {
var date2 = $('#start').datepicker('getDate', '+1d');
date2.setDate(date2.getDate()+1);
$('#end').datepicker('setDate', date2);
});
However, it doesn't seem to affect anything. Here is the whole example on jsFiddle:
http://jsfiddle.net/JW4jg/

Only display days of specific month in datepicker

I have a date picker and it is displaying a date. But the problem is each month is showing some days of previous month and also some days of next month which I don't want to be displayed. I want that each month should display days of that particular month.
For example let's say Month JUNE, here some days of month MAY and also some days of month JULY are displayed, but i want that only days of JUNE should be displayed. How can I do it? I am trying but no result is coming.
Here is the fiddle:
http://jsfiddle.net/cBwEK/
You can make the other month values invisible by adding:
​.datepicker .otherMonth {
visibility: hidden;
}
to your CSS. See the updated fiddle.

Categories