Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by ouyang on Jul 21, 2009 01:51
open dhtmlx forum
more questions about dhtmlxscheduler + database

Hi there,
I am almost getting there to save updated scheduler information to my postgresql database with scheduler.attachEvent function:
scheduler.attachEvent("onEventChanged", function(event_id,event_object){alert(event_object.start_date);return true;});
but I still have some problems as follows:

1. I can create xml_string with javascript at client side based on the data from the database, but fail load it in with
scheduler.load(xml_string);
Neither scheduler.loadXML(xml_string) nor scheduler.loadXMLString(xml_string) works.

2. The event_object.start_date in the above scheduler.attachEvent comes out in the format of:
Wed Jul 22 03:35:00 UTC+0800 2009
I would like it to be
"2009-07-22 03:35:00"
How can I configure it?

3. Do event_object's attributes correspond to the table fields (events.sql in the sample):

CREATE TABLE `events` (
`event_id` int(11) NOT NULL AUTO_INCREMENT,
`event_name` varchar(127) NOT NULL,
`start_date` datetime NOT NULL,
`end_date` datetime NOT NULL,
`details` text NOT NULL,
PRIMARY KEY (`event_id`)
)
The following four attributes are ok
event_object.event_id
event_object.start_date
event_object.end_date
event_object.text
Where are the event_name (event_object.event_name) and details (event_object.details)?

Thanks a lot for your help in advance.

ouyang


Answer posted by Support on Jul 21, 2009 06:08
>>1. I can create xml_string with javascript at client side based on the data from the database
On client side you can use addEvent command directly , without using XML as intermediate layer
http://dhtmlx.com/docs/products/dhtmlxScheduler/doc/dhtmlxscheduler___api_method_dhtmlxscheduler_addevent.html

>>comes out in the format
Actually it is a date object, it just auto-converts to string , when you are using it inside some string-based operations. 
You can define custom formatting method 
http://dhtmlx.com/docs/products/dhtmlxScheduler/doc/dhtmlxscheduler___date_formats.html#sch_dateformat


var convert = scheduler.date.date_to_str("%Y-%m-%d %h:%i:%s");
some_string = convert( ev.start_date );

>>3. Do event_object's attributes correspond to the table fields
If you are using connector as server side solution - all fields defined for connectors will be available on client side. 
If you generation xml by custom code - any child tag of "event" will be converted to property of event object 
Answer posted by Support on Jul 21, 2009 06:08
>> there to save updated scheduler information to my postgresql database
By the way, dhtmlxConnector lib can work with php+postgresql combination - so you can use ready server side solution for loading|saving data. 
Answer posted by ouyang on Jul 21, 2009 23:02
Thanks a lot. It is working now.