aurelia-kendoui-bridge icon indicating copy to clipboard operation
aurelia-kendoui-bridge copied to clipboard

Calendar: 'disableDates' runs before 'dates' is updated

Open avizcaino opened this issue 8 years ago • 4 comments

I have a KendoCalendar and each time the user navigates to a new month, it triggers a call to a service to retrieve available dates, which are stored in a property (let's call it availableDates) .

But I'm having problems with the k-disable-dates.call, which is triggered before the new dates are retrieved, and that makes that the disabled dates are calculated from the previous state of availableDates.

Is it possible to trigger the disableDates when receiving the new state of availableDates?

avizcaino avatar Oct 24 '16 11:10 avizcaino

Hi,

Could you create a gist.run that demonstrates this issue? Instructions can be found here

Thanks in advance!

JeroenVinke avatar Oct 24 '16 11:10 JeroenVinke

Here it is: https://gist.github.com/avizcaino/3fb287b1e8f191f0bce0d495383def80

As you can see, the server retrieves October 7th, and disableDates method disable all dates different to that one.

When changing to November, server returns 19th, but the since disableDates is run before the server returns data, the 19th is disabled...

avizcaino avatar Oct 24 '16 13:10 avizcaino

Thank you for the gist. The problem is actually not a race condition but something more difficult to fix unfortunately.

Kendo's datepicker control does not allow you to change dates after the control has been created. There is no method for it. Therefore the two-way binding of k-dates.bind does not have any effect. Here you can read more about this limitation

So you can only specify dates when you initialize the calendar. And therefore you need to destroy the calendar, and recreate it whenever you want to change the dates. This is something our bridge does not do well :(

Here I have demonstrated how to do this without the bridge: https://gist.run/?id=fc64b09d3eb2a6e1ca745a522db13528

I would like to try and see if the bridge could reliably recreate controls for scenarios like yours.

JeroenVinke avatar Oct 24 '16 17:10 JeroenVinke

@JeroenVinke Awesome, it is not the most efficient solution, but at least it'll solve my problem.

Thanks!

avizcaino avatar Oct 24 '16 19:10 avizcaino