Loading data from MSSQL using dhtmlxscheduler

Now how do i add a new event when i press save on the lightbox event ?
Check samples\01_initialization_loading\05_loading_mysql.html

next two lines define data saving script ( which is the same uri, which was used for data loading )

var dp = new dataProcessor("php/events.php"); dp.init(scheduler);

Where can i add the attachEvent to the scheduler
Any place after including dhtmlxscheduler.js

Also on the scheuler when i view in the browser IE
Can you provide a screenshot.
Beware that only standard mode ( page with full doctype ) is supported in case of IE.

Thanks Stanislav

Here is the screenshot of it .Please let me know what could be causing this to display in this fashion.


It looks as css conflict - probably some other stylesheet, which you are loadng on the page change styles for all elements on the page.

Thanks Stanislav ,
I iwill take a look.But i am having problems adding an event.
my init method looks something like this

function init() {
scheduler.config.xml_date="%Y-%m-%d %H:%i";
scheduler.config.details_on_create=true;
scheduler.config.details_on_dblclick=true;
scheduler.config.multi_day = true;
scheduler.config.api_date="%Y-%m-%d %H:%i";
scheduler.config.prevent_cache = true;

	scheduler.init('scheduler_here', new Date(2009,6,6), "month"); 
	scheduler.setLoadMode("month");
	
	scheduler.load("scheduler/events1.do");

	scheduler.attachEvent("onEventSave",function(id){
			  var start_date =scheduler.getEventStartDate(id);
			  var end_date = scheduler.getEventEndDate(id);
			  var textmessage =scheduler.getEventText(id);

			  scheduler.addEvent({
			  id: id,
			  start_date: start_date,
			  end_date: end_date ,
			  text: textmessage 
			  });




			  return true;
			});


	var dp = new dataProcessor("scheduler/events1.do");
	dp.init(scheduler);

}

Basically i am not able to add a new event when i click on save
Also getEventEndDate(event_id) returns null and so does getEventText(event_id)

Looks like my scheduler.attachEvent(“onEventSave”,function(id) has some problem .What ami doing wrong here ?

Also if i dont attachevent to the scheduler i am able to read from the database make changes from the lightbox like changing text and enddate and i click on save it is able to update the database

====================================
Log started, Tue Aug 03 11:42:50 EDT 2010

DB query
UPDATE events_manager SET start_date=‘2009-07-01 19:00’,end_date=‘2009-07-02 21:00’,text=’ Deepavali ‘,details=’ Bergen, Norway ’ WHERE event_id=‘37’

Done in : 15ms

But if i attachevent to the scheduler this doesnt work and it throws a null pointer exception in tomcat logs

ERROR [http-8080-Processor25] (StandardWrapperValve.java:260) - Servlet.service() for servlet scheduler_3 threw exception
java.lang.NullPointerException
at com.dhtmlx.connector.MSSQLDBDataWrapper.escape(MSSQLDBDataWrapper.java:23)
at com.dhtmlx.connector.DBDataWrapper.insert_query(DBDataWrapper.java:151)
at com.dhtmlx.connector.DBDataWrapper.insert(DBDataWrapper.java:199)
at com.dhtmlx.connector.DataProcessor.check_exts(DataProcessor.java:252)
at com.dhtmlx.connector.DataProcessor.inner_process(DataProcessor.java:198)
at com.dhtmlx.connector.DataProcessor.process(DataProcessor.java:117)
at com.dhtmlx.connector.BaseConnector.render(BaseConnector.java:292)
at com.dhtmlx.connector.BaseConnector.render_table(BaseConnector.java:210)
at Scheduler_Connector.configure(Scheduler_Connector.java:34)
at com.dhtmlx.connector.ConnectorServlet.doGet(ConnectorServlet.java:28)
at com.dhtmlx.connector.ConnectorServlet.doPost(ConnectorServlet.java:35)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:619)

My Scheduler_Connector class configure() method has the following
c.render_table(“events_manager”,“event_id”,“start_date,end_date,text,details”,"","");

What is missing here in the init method() ? Why dont i get the endeventdate ,text ?
Please let me know
TIA

Hello Stanislav,
I think i figured the problem there was a missing field (details) in the client side.So i added that so now its trying to update instead of doing a insert query when i add a new event.Am i missing something here ? what should i do such that its able to to update old events and insert new events into the database ? Please advise
Thanks

What is the purpose of the next code?

[code]scheduler.attachEvent(“onEventSave”,function(id){
var start_date =scheduler.getEventStartDate(id);
var end_date = scheduler.getEventEndDate(id);
var textmessage =scheduler.getEventText(id);

scheduler.addEvent({
id: id,
start_date: start_date,
end_date: end_date ,
text: textmessage
});[/code]

Because of it , before saving existing event - you are creating one more event, is it expected scenario? ( for default data saving you need not call addEvent - all will be done automatically )

In any case, you need to use unique IDs for each event

scheduler.addEvent({ id: scheduler.uid(), //unique ID
In case of existing code you are creating new event with same ID as already existing one , which confuses the scheduler

Thanks Stanislav
In other words an empty function with a return value true, should be fine right?

Also in the light box is it possible to omit the time and just show the date ? if possible what is the line of code for this?
TIA

In other words an empty function with a return value true, should be fine right?
Yes

Also in the light box is it possible to omit the time and just show the date
Can be done through code modification

time:{ render:function(){ ... var html="<select>"; //display:none can be added to this select box for (var i=first; i<last; i+=this.config.time_step*1){

Hello Stanislav,
From what you mentioned looks like the code is missing with no closing brackets and no code in the for loop.Does this change need to be done in dhtmxlscheduler.js or in jsp page ?
Please advise
Thanks

In addition to the above question
We are looking to provide a way to override the schedule with a different color lets say day 4 has a schedule and only on that day i want to override it with a no schedule and probably show it with a different color bar (red).On click of this event it should show me a no schedule data and not the day4 schedule does that make sense ? Please let me know if possible how we can achieve this
Thanks

From what you mentioned looks like the code is missing with no closing brackets
This is not full code, just locate the line from snippet and add display:none to tag

We are looking to provide a way to override the schedule with a different color lets say day 4 has a schedule and only on that day i want to override it with a no schedule and probably show it with a different color bar (red).

Not quite sure, but check
samples\02_customization\01_events_coloring.html
samples\02_customization\02_days_coloring.html

Hello Stanislav,
My apologies if i did not make this clear display:none will add this to the select tag.i want to remove the time dropdown box completely and all i should see is start date and end date ONLY.Hope this is clear now.How do we achieve this?
Thanks

If you will add “display:none” - you will never see the time selector - so only start and end dates will be shown, is there any difference between not-visible and not exist from practical point of view ?

You can create custom form section , to replace “time” but it will require a lot more of work.

Thanks Stanislav,
I will try this out and let you know how it goes.Now in the lightbox i want to list 7 days of week and each of the days will have a combo box or a drop down box allowing the user to select a particular schedule for that day which is retrieved from the database.At the bottom of the lightbox there is date selection for start date and end date.If i double click on Wednesday the start date and end date will show the date on wednesday which is what we want ,is it possible to show only wednesday on the lightbox with the combo box allowing the user to select the schedule for that day and like wise if he selects for a date range from monday to Friday the user should be able to see all the days of the week with their respective dropdown boxes allowing the user to select the schedule for that day.Please let me know

It can be done through custom form-block section
Check
docs.dhtmlx.com/doku.php?id=dhtm … ome_events

You can create few different selectboxes and based on active date show only necessary one.

Hello Stanislav,
I have enclosed the screenshot.I tried putting the schedule

under table and my jsp page has a menu which you can see on the left hand side .This is how i would like have the scheduler within our application frame so now whats happening is the events are slightlly moved to the left and even the schedule dates like 12:00 .How can they moved to the proper cell show that it indicates on that day?Please let me know
Thanks

Problem caused by the paddings between day cells.
You have some global css rule which sets padding to the TD elements and produces such view. Math used to calculate position of the events doesn’t take paddings in account - and as result incorrect view was generated.

Thanks Stanislav,
I have to dig into this but is it not the padding of the cells coming the scheduler?Just curious to see if any change can be done from the scheduler…Also when an event is between 2 dates and i drag it to a different date it automatically updates the database .I want to throw a message “do you want to change the date for this event” if yes it should update and if the user selects no it shouldnt .The purpose of this is we dont want the users to accidently change the dates by dragging and dropping but in case he does it we want to confirm that before we update the database .Please let me know

Scheduler sets padding:0 for the cells in month view, and any altering may affect position calculation.

Also when an event is between 2 dates and i drag it to a different date it automatically updates the database .
Check
viewtopic.php?f=6&t=14629&p=43878

Thanks Stanislav,
In response to this question on lightbox Now in the lightbox i want to list 7 days of week and each of the days will have a combo box or a drop down box allowing the user to select a particular schedule for that day which is retrieved from the database.At the bottom of the lightbox there is date selection for start date and end date.If i double click on Wednesday the start date and end date will show the date on wednesday which is what we want ,is it possible to show only wednesday on the lightbox with the combo box allowing the user to select the schedule for that day and like wise if he selects for a date range from monday to Friday the user should be able to see all the days of the week with their respective dropdown boxes allowing the user to select the schedule for that day.Please let me know

You sent me a link in response to custom form block events.That link did not help me much as i tried what was mentioned there Here is what my code looks like

function init() {
scheduler.config.xml_date=“%Y-%m-%d %H:%i”;
scheduler.config.details_on_create=true;
scheduler.config.details_on_dblclick=true;

scheduler.init(‘scheduler_here’,null,“month”);
scheduler.locale.labels.section_type = “Monday”;
scheduler.locale.labels.section_type1 = “Tuesday”;
scheduler.locale.labels.section_type2 = “Wednesday”;
scheduler.locale.labels.section_type3 = “Thursday”;
scheduler.locale.labels.section_type4 = “Friday”;
scheduler.locale.labels.section_type5 = “Saturday”;
scheduler.locale.labels.section_type6 = “Sunday”;

scheduler.attachEvent(“onBeforeLightbox”,function(id){
scheduler.load(“scheduler/lightbox”);
return true;
});

scheduler.config.lightbox.sections = [
{name:“description”, height:200, map_to:“text”, type:“textarea” , focus:true},
{name:“type”, height:21, map_to:“NAME”, type:“select”, options:[scheduler.serverList(“NAME”)]},
{name:“type1”, height:21, map_to:“NAME”, type:“select”, options:[scheduler.serverList(“NAME”)]},
{name:“type2”, height:21, map_to:“NAME”, type:“select”, options:[scheduler.serverList(“NAME”)]},
{name:“type3”, height:21, map_to:“NAME”, type:“select”, options:[scheduler.serverList(“NAME”)]},
{name:“type4”, height:21, map_to:“NAME”, type:“select”, options:[scheduler.serverList(“NAME”)]},
{name:“type5”, height:21, map_to:“NAME”, type:“select”, options:[scheduler.serverList(“NAME”)]},
{name:“type6”, height:21, map_to:“NAME”, type:“select”, options:[scheduler.serverList(“NAME”)]},
{name:“time”, height:72, type:“time”, map_to:“auto”}
];

scheduler.attachEvent(“onEventSave”,function(id){
return true;
});

}

My light box connector looks like this
protected void configure() {
Connection conn= ( new DataBaseConnection()).getConnection();
SchedulerConnector c = new SchedulerConnector(conn,DBType.MSSQL);
OptionsConnector list = new OptionsConnector(conn,DBType.MSSQL);
list.render_table(“TABLE_TEMPLATES_LIST”,“TEMPLATE_ID”,“TEMPLATE_ID(value),name(label)”);
c.set_options(“NAME”, list);
c.render_table(“TABLE_TEMPLATES_LIST”,“TEMPLATE_ID”,“USERID,NAME,DESCRIPTION,IsGlobal”,“”,“”);

}

The query that is executed
DB query
SELECT TEMPLATE_ID,TEMPLATE_ID as value,name as label FROM TABLE_TEMPLATES_LIST

Done in : 140ms

Below is the screenshot of the data in the table.The labels should be populated in the dropdown boxes and key values should contain the values of ID.

First .
Why am i not getting the values populated in the dropdown boxes?
In the lightbox.js i did not find a function where onselectdate() can be used to hide elements in the lightbox .On a selecting a date i should be able to hide and show the combo boxes
Your sample code to hide elements in the custom form blocks is not clear i did try that .Can you please explain if this is the above code what modifications do i need to do here

Secondly
Assuming you will be answer the above question what methods do i have to get the values from the combo boxes to insert the values in the database ? please give a sample code with dropdown box or combo box as a example

Thirdly
If the event shows up in the scheduler interface and i click on that i would like to show that details of the schedule again with the combo boxes .For eg lets say the schedule is for thursday and Friday and when i do a double click on the event it should bring the lightbox with the combo boxes for thursday and friday ONLY with the appropriate scheudule selected and the date as well.

Also The sceduler generates a eventid is this unique? the reason i am asking is it should NOT generate a duplicate value as we are inserting this in the DB and it should not clash with the other events if it matches the event id

Please let me know the answers for all the above questions
Thank you in advance