aurelia-ui-toolkits / aurelia-kendoui-bridge

MIT License
117 stars 31 forks source link

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

Open avizcaino opened 8 years ago

avizcaino commented 8 years ago

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?

JeroenVinke commented 8 years ago

Hi,

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

Thanks in advance!

avizcaino commented 8 years ago

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...

JeroenVinke commented 8 years ago

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.

avizcaino commented 8 years ago

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

Thanks!