Hello,
I need help ...
I have 2 DatePickers in which certain dates are deactivated according to a database :
wixData.query ("News")
. eq ("dispo", true )
. limit (1000)
. find ()
. then ((res) => {
let items = res.items ;
if (items.length > 0) {
let disabledDates = [ ] ;
items.forEach (e => {
disabledDates.push (e.date) ;
} )
$w ("#datePicker1").disabledDates = disabledDates
$w ("#datePicker2").disabledDates = disabledDates
}
} )
I use a 2nd code so that the date selected in DatePicker1 is the minimum date that can be selected in DatePicker2:
export function datePicker1_change(event) {
let firstTime = event.target.value.getTime();
let timeTwoDaysHence = firstTime + (1 * 86400000) ;
let dateTwoDaysHence = new Date(timeTwoDaysHence) ;
$w('#datePicker2').minDate = dateTwoDaysHence ;
Now I would like the maximum selectable date in DatePicker2 to be the first deactivated date after the selected date in datePicker1. I hope to have been clear...
Is it possible to maxDate?
I have tried a multitude of formulas but cannot do it ... can someone help me?
Yes it is possible:
const disabledDates = $w('#datePicker2').disabledDateRanges.map(e => new Date(e.startDate).getTime()); $w('#datePicker2').maxDate = new Date(disabledDates.find(e => firstTime < e));