V4 dataprocessor problem

Hi,
I’m testing V4.1 Pro of the dhtmlx suite. I have noticed that V4 of the dp behaves differently to earlier versions.

[code]…

... var mnutree = new dhtmlXMenuObject(); ... mnutree = atabbar.cells("a1").attachTree(); mnutree.setImagePath("codebase/imgs/csh_vista/"); mnutree.setStdImages("leaf.gif","leaf.gif","leaf.gif"); mnutree.setOnClickHandler(function(id){fetchStuff(id);}); mnutree.enableSmartXMLParsing(true); mnutree.enableItemEditor(true); mnutree.enableDragAndDrop(true); mnutree.setDragBehavior("complex"); mnutree.enableKeyboardNavigation(true); // PRO Edition mnutree.enableKeySearch(true); // PRO Edition
	mnutree.enableContextMenu(mnumenu);
	mnutree.attachEvent("onBeforeContextMenu", function(itemId) {
		if (mnutree.hasChildren(itemId) > 0) {
			mnumenu.hideItem('outher');
			mnumenu.showItem('branche');
		} else {
			mnumenu.showItem('outher');
			mnumenu.hideItem('branche');
		}
		return true;
    });

mnutree.loadXML(“model/m_get_site.php”);
var myDP_org = new dataProcessor(“model/upd_tree_things.php”);
myDP_org.init(mnutree);
[/code]
In upd_tree_things.php

[code]…
/*
/* Stuff that is passed in from the dataprocessor that you don’t get to see.
/* tr_id
/* tr_pid
/* tr_text
/* !nativeeditor_status
*/
$posted = array();
if (!empty($_GET)){
foreach ( $_GET as $key => $value ){
if ( ( !is_string($value) && !is_numeric($value) ) || !is_string($key) )
continue;

	if ( get_magic_quotes_gpc() )
		$value = htmlspecialchars( stripslashes((string)$value) );
	else
		$value = htmlspecialchars( (string)$value );

  $posted[$key] = $value;
}

} else {
// some error handling hear
return;
}
fwrite($fh, print_r($posted, true) . “\n”);[/code]
In Ver 3.0 and earlier the response in the logging file looks like:

Array ( [tr_id] => 24858 [tr_text] => New item [tr_pid] => 24238 [tr_order] => 1 [!nativeeditor_status] => updated )
In V4.1 the posted array looks like:

Array ( [editing] => true )

How is it possible to process the data in V4?

gloworm

In v4 dhtmlx.js includes both dataprocessor.js and connector.js. So dataprocessor uses a bit different data encoding logic. To revert it back you can use code like next

var myDP_org = new dataProcessor("model/upd_tree_things.php"); myDP_org.init(mnutree); myDP_org.setTransactionMode("GET", false);

Hi, I had already tried the setTransactionMode without success.

The upd_tree_things.php has no errors and works as required when manually inserting records:
…/upd_tree_things.php?tr_id=987789111&tr_text=News2&tr_pid=24099&tr_order=1&!nativeeditor_status=inserted

[code]2015-04-28 07:19:50
Array
(
[tr_id] => 2789111
[tr_text] => News1
[tr_pid] => 24099
[tr_order] => 0
[!nativeeditor_status] => inserted
)

2015-04-27 21:19:50
0.57538400 1430168982
Write header
Done
2015-04-28 07:22:07
Array
(
[tr_id] => 987789111
[tr_text] => News2
[tr_pid] => 24099
[tr_order] => 1
[!nativeeditor_status] => inserted
)

2015-04-27 21:22:07
0.57538400 1430168982
Write header
Done[/code]
I tried the setTransactionMode as true and false, both before and after the init method

myDP_org.setTransactionMode("GET", true); myDP_org.init(mnutree);

The result is still the same:

[code]2015-04-28 07:26:42
Array
(
[editing] => true
)

2015-04-27 21:26:42
0.46942600 1430134027
Write header
Done
2015-04-28 07:29:49
Array
(
[editing] => true
)

2015-04-27 21:29:49
0.46942600 1430134027
Write header
Done
2015-04-28 07:30:56
Array
(
[editing] => true
)

2015-04-27 21:30:56
0.46942600 1430134027
Write header
Done
2015-04-28 07:32:07
Array
(
[editing] => true
)

2015-04-27 21:32:07
0.46942600 1430134027
Write header
Done
[/code]

Any other ideas?

I am noticing that the POST variables sent in the V4 includes some type of id in front of it and I can no longer us gr_id, etc. Instead it shows as 20_gr_id, for example. Is there documentation somewhere that talks about how this should be coded in V4? I couldn’t find it.

Please change order of calls, as it was in my snippet

myDP_org.init(mnutree);
myDP_org.setTransactionMode(“GET”, true);

You need to use setTransactionMode AFTER init, as during initialization the different mode will be set

Thanks Stan. I was able to get it to start using GET instead of POST, but the variables all have a number in front of them and I’m not sure the proper way to code to receive them in my dataprocessor php file. Where I used to get “gr_id” and “c0”, “c1”, etc., I am not getting “20_gr_id” and “20_c0” and “20_c1” and so on. But sometimes it changes to another number.

Never mind. I see my problem. I just set the second parameter in the setTransactionMode function to “false” so that it only sends one at a time. I appreciate your help. All works well with v4 and the grid now for me.

Stanislav, This is fun!
In my previous post I stated that I had tried all permutations of the setTransactionMode - FALSE - TRUE - AFTER - BEFORE without (desired) effect. I have just tried TRUE with AFTER and got a result that I didn’t get before - caching issue? The result was unexpected (absence of documentation) ie. something different to earlier versions of DHTMLX but at least something to work with.

myDP_org = new dataProcessor("model/upd_tree_things.php"); myDP_org.init(mnutree); myDP_org.setTransactionMode("GET", true);
The model/upd_tree_things.php snippet

[code] $posted = array();
if (!empty($_GET)){
foreach ( $_GET as $key => $value ){
if ( ( !is_string($value) && !is_numeric($value) ) || !is_string($key) )
continue;

	if ( get_magic_quotes_gpc() )
		$value = htmlspecialchars( stripslashes((string)$value) );
	else
		$value = htmlspecialchars( (string)$value );

  $posted[$key] = $value;
}

} else {
// some error handling hear
return;
}

fwrite($fh, print_r($posted, true) . “\n”);

//$ip=$_SERVER[‘REMOTE_ADDR’];
//$ip=‘Unknown’;
$activated = gmdate(“Y-m-d H:i:s”);
fwrite($fh, $activated . “\n”);
//start session
error_reporting(E_ALL ^ E_NOTICE);

session_start();
if(!isset($_SESSION[“id”])){
$_SESSION[“id”] = microtime();
}

fwrite($fh, $_SESSION[“id”] . “\n”);
[/code]
My logging returned the following:

[code]2015-04-29 05:21:58
Array
(
[editing] => true
[1430248918129_tr_id] => 1430248918129
[1430248918129_tr_pid] => 24099
[1430248918129_tr_order] => 2
[1430248918129_tr_text] => New item
[1430248918129_!nativeeditor_status] => inserted
[ids] => 1430248918129
[dhxr1430248918129] => 1
)

2015-04-28 19:21:58
0.25200600 1430248918[/code]
The other poster (robstan) observed that

. It appears that such id is Epoch time plus milliseconds as confirmed by setting $_SESSION(“id”) = microtime().
However, I’m not sure what robstan meant by

when using the FALSE argument.
Out of curiosity I set the argument back to FALSE and tested in Firefox (V37.0.2). I had been using Google Chrome (Version 42.0.2311.90 m) previously.

myDP_org = new dataProcessor("model/upd_tree_things.php"); myDP_org.init(mnutree); myDP_org.setTransactionMode("GET", false);
Firefox appeared to work - inserting a leaf and no milli-time prefixing:

[code]2015-04-29 06:01:51
Array
(
[editing] => true
[tr_id] => 1430251311014
[tr_pid] => 24099
[tr_order] => 2
[tr_text] => New item
[!nativeeditor_status] => inserted
[dhxr1430251311019] => 1
)

2015-04-28 20:01:51
0.04310500 1430251311[/code]
Updating the leaf’s name and order (drag-n-drop) worked as expected

[code]2015-04-29 06:03:56
Array
(
[editing] => true
[tr_id] => 24860
[tr_pid] => 24099
[tr_order] => 2
[tr_text] => News3
[!nativeeditor_status] => updated
[dhxr1430251436808] => 1
)

2015-04-28 20:03:56
0.25200600 1430248918

2015-04-29 06:44:15
Array
(
[editing] => true
[tr_id] => 24860
[tr_pid] => 24099
[tr_order] => 1
[tr_text] => News3
[!nativeeditor_status] => updated
[dhxr1430253855030] => 1
)

2015-04-28 20:44:15
0.04310500 1430251311[/code]
Now I’m left wondering why, when using the setTransactionMode(“GET”, false) method previously, it didn’t work as expected.

Thanks for your assistance.