I'm using react-day-picker DayPicker (not DayPickerInput) and have an existing element I want to use to drive the date popup. I can't figure out how to pre-feed the date from the element to the calendar and highlight the given date. All the other functionality, e.g. capturing the user chosen date and populating the element are working fine. So if my input element has Nov 11, 2019, and I click on it, I want the popup to go to that date and show it as selected. The current behavior is that it shows the current month and date. I've tried to set the selectedDays={this.state.selectedDay}, but that doesn't seem to work. Note that I am new to reactjs, and this could be the gap in my understanding.
Thanks for any suggestions you may have.
Found at least one way to achieve the behavior I was looking for. There is a DayPicker property "initialMonth" that will display the current month. Note that this only needs to be populated only with year and month:
initialMonth = {new Date(selectedDate.getFullYear(), selectedDate.getMonth())}
Related
Currently Im developing an datepicker from hackerone react datepicker, where user can select date from day up to decade, but I didnt find any props in DatePicker component at their website to give user opportunity to select decade, maximum is a year selection. I decided to put prop yearItemNumber={100} so it will give a range of 100 years, but how can I combine 10 years into one option as it show in first screen?
How it may look:
What I have:
Also additional question, how can I display a century in datepicker header? Or its just a hardcoded text
I am currently working on a project where the given user needs to fill out a form to add an activity. There is a filter which selects which month this applies to. There is a calendar where a date is selected from. The issue is that the calendar works properly when the current date is in the selected month as such:
The current month popup view
The current month filter
But when the filter is applied to a month that isn't the current one, the view lacks behind as such:
The current month filter
The error full popup
I have tried the use of the active start date yet, I can't seem to ensure that the active start date is applied for the month. Are there any known solutions? I have my code snippet attached below:
Code of the parameters
Code of the React Component Returned
The date is given by another component which is updated with the use state according to the filter applied.
I am using DayPicker in overlay. I have set the selected from date as 17th August 2020 and I am setting DayPicker to show months from current to 12 months onward.
I want my DayPicker to scroll into selected date month (which is August in our case). But it is showing current month as default open.
I have tried multiple combination of props available, but nothing helps.
I have created a codesandbox for the same.
https://codesandbox.io/s/react-day-picker-examplesselected-dz5pv?file=/example.js
PS: I can do this by Javascript, but I want to know if there is any default props available for this.
Is there any property , option available in the date picker control so that if user want to select today from any date from current date ?
e.g if user is view current month of last year then he has the option to select current date ?
just see this link and how they are implementing the Today button in the Datepicker WPF Toolkit). This link is from the WPFToolkit discussion forum. May be this will help you.
http://wpf.codeplex.com/Thread/View.aspx?ThreadId=85516
i think there is no option that there is a button directly in the control.
You can use a button outside the control, or something like this to set the current date.
Or you build a custom control....
I just hacked together a simple example. It is VS 2010. www.mbgr.de/CurrentDateWpf.zip.
No warranty at all on this one. Use at your own risk :-)
I am using DateTimePicker with Australian date formatting set (dd/mm/yyyy)
The problem is when user enters a day which is outside of the month (mm), control resets that day to "1".
This obviously is a quite confusing obstacle for user - it's not natural to enter the month first and then enter the day [culture-wise]
Is there a way to disable this validation or postpone it till say,when control loses focus?
Thanks!
I've tried and I do not see anyway we can disable this for on micro-validation via the DateTimePicker's properties.
I know your frustration when the current date is "09/11/2009" (dd/MM/yyyy) and a user wants to enter "31/12/2009" via the keyboard from left to right.
Upon htting "31", it'll revert to "1" as Nov has only 30 days. It will show "2" if "32" is entered.
It forces the user to enter the month first followed by the day. I.e. entering in the direction of right, left, far-right.
My suggestion is use a more generic form of format like yyyy-MM-dd which though does not follow your regional/cultural format, still is easily understood by the user (or Aussie friends).
Another option might be to instantiate an edit control and overlay it on top of the date time picker's edit, and use the value to set the date time picker's value. Of course, you'll need to do some validation before doing the setting; and you'll also want to mimic the way the date time picker's edit field allows you to select the date, month and year individually.