Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Tim Sanders on Aug 17, 2009 13:42
open dhtmlx forum
Scheduler - render event

We are using AJAX to do some validation when an event is changed. If there is a warning we display the message and let the user determine whether to continue with the change. If they choose not to make the change we restore the original values with the following function:


    
    function restoreOriginal() {
     //Restore original values to scheduled S/O
     var id = globalid;
     var ev = globalev;
//put original data back
scheduler.getEvent(id).start_date = ev.orig_start_date;
scheduler.getEvent(id).end_date = ev.orig_end_date;
scheduler.getEvent(id).tech = ev.orig_tech;
scheduler.getEvent(id).priority = ev.orig_priority;
scheduler.updateEvent(id); // render updated event
}

The values seem to be restored, but the scheduler.updateEvent(id) statement does not render the changed event. The event simply disappears from the scheduler.

Is updateEvent the correct method to redisplay an event after changing its values?

Thanks.
Answer posted by Support on Aug 18, 2009 02:22
>>Is updateEvent the correct method to redisplay an event after changing its values? 
yes, this method is purposed to force redrawing of event, so it is a correct use-case


>>The event simply disappears from the scheduler.
Most probably the start or end date is incorrect. 
Be sure that ev.orig_start_date and ev.orig_end_date are valid Date objects ( not a string representation of the date ) 
Answer posted by Tim Sanders on Aug 25, 2009 14:56
I am bringing these fields (ev.orig_start_date and ev.orig_end_date) in as XML data just like start_date and end_date.  How do I know/control whether these are valid Date objects rather than string representations?
Answer posted by Support on Aug 26, 2009 01:28
When setting this value by js command, as in above case

scheduler.getEvent(id).start_date = ev.orig_start_date;

you need to be sure that ec.orig_start_date is js Date object, not the string 

When loading data from xml, the format of data described by 
        scheduler.config.xml_date
default format is %m/%d/%Y %H:%i