First, love the control, love the MVC wrapper, love the extensibility, love the support and available help. Now to the issue!
I have created a custom edit template which includes resources. However, I want some of those resources to not be displayed if the difference between the event start and the time the user double clicks the event is, say, greater than 24 hours.
I used the Scheduler edit event to set a variable in a javascript function like so...
.Events(e => { e.Edit("checkValidCancelDate"); }
The function (and global variable):
var showCancelOptions = true;
function checkValidCancelDate(e) {
var start = e.event.start;
var now = new Date();
var startMs = start.getTime();
var nowMs = now.getTime();
var hours = (startMs - nowMs) / (1000 * 60 * 60);
if (hours <= 24) {
showCancelOptions = false;
}
}
That all works, but here is the kicker...if I check for that variable with my sweet custom script for the editor template, the variable's value isn't set appropriately, and the resources display. The script (inside the editor template script) looks like..
if (resources[resource].title != 'I plan on:' || showCancelOptions) {
... 8< ... classic Kendo resource display template code goes here
}
Because that script actually runs BEFORE the edit event is handled!!! I have verified this with alert statements. So the second time the user edits the event, it actually works (the resources don't display), because the editor template script takes the value of the variable from the previous edit click!!!
So, my question is, is there a way to make the edit event fire BEFORE the custom editor template script runs to generate the HTML for the modal dialog that pops up? Or similarly, is there a way to make the event edit dialog be constructed and shown AFTER the edit event has fired?
Thanks in advance!
Adam
I have created a custom edit template which includes resources. However, I want some of those resources to not be displayed if the difference between the event start and the time the user double clicks the event is, say, greater than 24 hours.
I used the Scheduler edit event to set a variable in a javascript function like so...
.Events(e => { e.Edit("checkValidCancelDate"); }
The function (and global variable):
var showCancelOptions = true;
function checkValidCancelDate(e) {
var start = e.event.start;
var now = new Date();
var startMs = start.getTime();
var nowMs = now.getTime();
var hours = (startMs - nowMs) / (1000 * 60 * 60);
if (hours <= 24) {
showCancelOptions = false;
}
}
That all works, but here is the kicker...if I check for that variable with my sweet custom script for the editor template, the variable's value isn't set appropriately, and the resources display. The script (inside the editor template script) looks like..
if (resources[resource].title != 'I plan on:' || showCancelOptions) {
... 8< ... classic Kendo resource display template code goes here
}
Because that script actually runs BEFORE the edit event is handled!!! I have verified this with alert statements. So the second time the user edits the event, it actually works (the resources don't display), because the editor template script takes the value of the variable from the previous edit click!!!
So, my question is, is there a way to make the edit event fire BEFORE the custom editor template script runs to generate the HTML for the modal dialog that pops up? Or similarly, is there a way to make the event edit dialog be constructed and shown AFTER the edit event has fired?
Thanks in advance!
Adam