Gantt - dataProcessor auto update

Hi,

I’m trying to use the dataProcessor autoUpdate function of the Gantt chart, and the first call to the ASP.NET MVC backend works fine, but the second call results in the attached screenshot.

Any ideas?

Regards
Jacques


Make sure you’ve specified correct content type of the dataProcessor response. It uses xml so content type must be ‘text/xml’

I have found this error message only when I added a new task. The dataprocessor is working on update, properly.
Where is the place in the code, where the dataprocessor response can setup for text/xml ???

Please provide more details on how you process update on the server-side. How do you generate a responce for the dataprocessor? Since there is no .Net version of dhtmlxConnector for Gantt, you must be doing it manually - make sure it’s valid xml with correct content type
docs.dhtmlx.com/doku.php?id=dhtm … e#response

You may check how it can be done for dhtmlxScheduler (format for update/insert/delete responces will be exactly the same)
dhtmlx.com/blog/?p=639

My process use MS SQL database and JSON connector. Every updating process are working correctly.
The correct log like this:

row 165 marked [updated,valid]
Initiating data sending for 165
Initiating data sending for all rows
Sending all data at once
Server url: connector_mssql.php?x=578908&editing=true&gantt_mode=tasks parameters
Server response received details
Action: updated SID:165 TID:165
row 165 unmarked [updated,valid]

BUT, when I make insert (from “plus” button), the log like this:

row 1381858046749 marked [inserted,valid]
Initiating data sending for 1381858046749
Initiating data sending for all rows
Sending all data at once
Server url: connector_mssql.php?x=578908&editing=true&gantt_mode=tasks parameters
Server response received details
Not an XML, probably incorrect content type specified ( must be text/xml ), or some text output was started before XML data

I am afraid the main problem is with the identity. Because in the database the MS SQL generate a new identity what is 217, in this case. The client wants to update the row with “1381858046749” number, but that is wrong identity. Naturally, this problem is live in MS SQL, because the identity rules are different than in MYSQL.

AND naturally, the updating processes are unserviceables on the side of database (no problems on the client side).

BUT when I reload the complete gantt, the new task get the correct identity, so every updating process are working correctly.

The question: Have you got something event handling what is able to repair the identity number on client side after the database made the final identity of the new added task ???

and JSON connector
Can you post the connector’s configuration.
Normally it must not push a temp ID into the database. ( Gantt doesn’t differ much from other connectors, and they can work with MsSQL identity )

This is my connector:

<?php include ('codebase/connector/db_sqlsrv.php'); include ('codebase/connector/gantt_connector.php'); // MS SQL $dbtype = "SQLSrv"; $serverName = "(local)\EWORDOC2"; $connectionInfo = array( "Database"=>"GANTT", "CharacterSet"=>"UTF-8" ); $conn = sqlsrv_connect( $serverName, $connectionInfo); $gantt = new JSONGanttConnector($conn,$dbtype); $gantt->enable_order("id"); $gantt->render_links("gantt_links","id","source,target,type"); $filterstring = "ProjAZ=".$_GET["x"] ; $gantt->filter($filterstring); $gantt->render_table("gantt_tasks","id","start_date,duration,text,progress,parent,Update_sw,T_Typ,WBS,ProjAZ,sortorder"); ?>

AND I have this on client side:

gantt.attachEvent(“onAfterTaskAdd”, function(id, item) {
item.ProjAZ = 999999
item.T_Typ = “T”
item.Update_sw = 1
item.sortorder = 1
dhtmlx.message("ProjAZ: " + id);
});

Every update works perfectly, but I have problem with adding a new task. The task is created in the database, but the client is not able to rename and update the database data from lightbox, neither from drag&drops, only after I reload the hole Gantt.

a) Please beware that onAfterTaskAdd may be processed after sending data to the server side. If you want to have it before sending to server side, you need to place this code before dp.init()

The better strategy will be to use onBeforeTaskAdd, which will fire before data sending for sure.

b) The server side code looks valid, it must not try to save ID in the database. Try to add logging - it will contains details about possible error.

$gantt = new JSONGanttConnector($conn,$dbtype);
$gantt->enable_log(“log.txt”);

c) You can try to update gantt_connector.php with the attached one ( fixes in it is not related to your case, but solves some other problems with data saving )
gantt_connector.names2.zip (2.5 KB)

I deleted the onaftertaskadd event and the filterstring
Well, the log is very interesting.
In first, when I pushed the “+” button, created the id=259 task in the database.
I attached this log: “after_+.log”.

The new task is showed itself in the client (and in the database) and the lightbox shows the data of new task.

Then I repaired the task text for “Lightbox text” and I saved.

After the saving I made a new log: “after_lightbox.log”

In the database are 2 different tasks (id259 AND id260 !!) for one new task !!
log.rar (2.23 KB)

I am sorry to say, but yesterday I mixed the column names in render_table. When I repaired the order of column names the double new task effect was terminated.

BUT the original problem is live when I pushed the “+” sign:

Error type: Load XML
Description: Incorrect XML

The dynamic log:
row 1382082425745 marked [inserted,valid]
Initiating data sending for 1382082425745
Initiating data sending for all rows
Sending all data at once
Server url: connector_mssql.php?editing=true parameters
Server response received details
Not an XML, probably incorrect content type specified ( must be text/xml ), or some text output was started before XML data

The log file in attachment.

AND the main problem is the lightbox what is not able to save nothing new information for new task.

No log file insert in this case !!!
after_+.rar (522 Bytes)

I have found a big mistake. In my database the date column was “date” instead of datetime.
This was the cause of incorrect XML. All right! Good news!

BUT, the double tasks problem returns:

The log:

INSERT INTO gantt_tasks(start_date,duration,text,progress,parent)
VALUES (‘2012-12-20’,‘1’,‘New task’,‘0’,‘2’);
SELECT SCOPE_IDENTITY() as dhx_id
SELECT MAX(id) as maxvalue FROM gantt_tasks
UPDATE gantt_tasks SET id = 1 WHERE id = 19
exception ‘Exception’ with message 'SQLSrv operation failed

420008102[Microsoft][SQL Server Native Client 11.0][SQL Server]Cannot update identity column ‘id’.
’ in C:\inetpub\wwwroot_ohptc\GANTT\codebase\connector\db_sqlsrv.php:31
Stack trace:
#0 C:\inetpub\wwwroot_ohptc\GANTT\codebase\connector\db_common.php(662): SQLSrvDBDataWrapper->query(‘UPDATE gantt_ta…’)
#1 C:\inetpub\wwwroot_ohptc\GANTT\codebase\connector\dataprocessor.php(170): DBDataWrapper->new_record_order(Object(DataAction), Object(DataRequestConfig))
#2 C:\inetpub\wwwroot_ohptc\GANTT\codebase\connector\dataprocessor.php(97): DataProcessor->inner_process(Object(DataAction))
#3 C:\inetpub\wwwroot_ohptc\GANTT\codebase\connector\base_connector.php(491): DataProcessor->process(Object(DataConfig), Object(DataRequestConfig))
#4 C:\inetpub\wwwroot_ohptc\GANTT\codebase\connector\gantt_connector.php(128): Connector->render()
#5 C:\inetpub\wwwroot_ohptc\GANTT\codebase\connector\base_connector.php(410): GanttConnector->render()
#6 C:\inetpub\wwwroot_ohptc\GANTT\connector_mssql.php(31): Connector->render_table(‘gantt_tasks’, ‘id’, ‘start_date,dura…’)
#7 {main}
Edit operation finished
0 => action:error; sid:1382084428571; tid:19;
Done in 0.015599966049194s

I have missed that while checking your code first time

If you need to load task ordered by their id, change the next line

$gantt->enable_order("id");

like

$gantt->sort("parent, id")

sort - defines sortering order
enable_order - instructs connector to use the provided field for storing the order or item

If you wish to use enable_order - you need a separate integer field in the database for such task ( sortorder in default samples, can be named differently in your case )

Thank you, Stanislav!
Great!
The knowledge is power! :stuck_out_tongue:

By the way, there are some lessons for us in this creamy tragedy:

1./ The database column must be “datetime” - the updating process working with “date”, but the insert do not!
2./ The order of columns at “render_table” is extremely important in case of insert:
start_date, duration, text…
3./ “enable_order” does not working with “id” ($gantt->enable_order(“id”)-wrong!!), the $gantt->sort(“parent,id”) is correct code.

Thank you!