Tree: Dataprocessor, multiple updates

Hello,



i want the user give the chance, to drag&drop more than one item. This can be done by:



tree.enableMultiselection(true);



But in the update routine the update handler will be called more than one time: it depends on the amount of selected nodes.



In my case i am updating no database, which can be quickly accessed. Instead i am updating databse entries on a remote

system via webservice. This system itself uses lock mechanism to ensure transactional correctness. But if i fire the

update events to o quick, i will run in a situation, there i want to update the parent when it is locked by the prior update process.

A better approach is, to get all nodes, which have to be update only once via the data processor, so that i am able

to do the time consuming update procees in one step and not in more.



To illustrate my desire:



Folder 1

|

— Item 1

|

— Item 2



Folder 2



I want to drag the item 1 and item 2 from folder 1 to folder 2. The dataprocessor initiates 2 calls, but i want only one call with the information about the amount of items to be moved.



Is there any solution?





Best regards,

Stefan















Current version of dataprocessor supports mass-update mode for dhtmlxgrid only, it can’t be used with dhtmlxtree.
If you interested we can provide a beta version which can work in necessary mode with dhtmlxtree, only other possible solution - manual iteration through dp.updatedRows collection with manual information collection and data sending.


Hello,



 



at this point i want to gratulate about your fast reply. I never got information/answers more quickly than from your support site. I am interested in the beta version.



Best regards, Stefan



 


Hello ,



 



i have found out, that then i set 

SPAN { font-family: "Arial monospaced for SAP"; font-size: 8pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; }

dataProcessor.setUpdateMode(“off”);  and implement a svae function instead with dp.sendData, the system does one call after another and not simultaniously.



Now i have a really chance to do all one to anothers. If i am able to find out, how much times the dataprocessor calls the update routine i can collect all request in the backend and biuld one large



update request.



 



I know the methdo getSyncState, but this doesnot deliver the outstanding updates. Must i use the method checkBeforeUpdate to collect the info on the client



side via javascript or is there onother comfortable method?



 



Best regards,
Stefan


Hi dhtmlx-support-team,



further tests brought out: i have my tree with mode



tree.enableMultiselection(true);
dataProcessor.setUpdateMode(off);



If i now update the tree at once with dataProcessor.sendData() following happens:



I have selected 8 nodes to be dropped from one folder to another. Now 8 calls to my dataprocessor url will be fired:



1) All informations about all 8 nodes
2) Information about 7 nodes




8) information about 1 node.



Bug or feature? I can process zthe information about the first call. How can i avoid the system to call me 7-times again?



Best regards, Stefan



 









 









 




folders.txt (19.1 KB)


Hi,



 



i have seen that in thsi case now a new field beneath



SPAN { font-family: "Arial monospaced for SAP"; font-size: 8pt; color: #000000; background: #FFFFFF; }

tr_id
tr_order
tr_pid  
tr_text 




will be delivered: ids, but it is not clear, what information this field should contain.

I know the methdo getSyncState, but this doesnot deliver the outstanding updates.
You can use the next logic ( it based on inner methods )


for (var i =0; i<dp.updateRows.length; i++){ //for each updated item
var id=dp.updateRows[i];
var params=this._getRowData(rowId);
//here you have all parameters for updated item as URL encoded string
}

. Now 8 calls to my dataprocessor url will be fired:
When multiple row dragged, each row generate separate update event, which result in 8 update events, where each must send info only about 1 updated item.
Problem can occur if you are using old version of dataProcessor lib, which doesn’t prevent multiple-calls for the same row
Latest version of dhtmlxDataprocessor.js sent by email.

will be delivered: ids, but it is not clear, what information this field should contain.
In current version of dataProcessor it supported by dhtmlxgrid only.

Beta version of updated dataprocessor.js sent by email. In case of mass update it will send data as

1232981683177_tr_id=1232981683177
1232981683177_tr_pid=0
1232981683177_tr_order=5
1232981683177_tr_text=New%20item
1232981683177_!nativeeditor_status=inserted
1232981683408_tr_id=1232981683408
1232981683408_tr_pid=0
1232981683408_tr_order=6
1232981683408_tr_text=New%20item
1232981683408_!nativeeditor_status=inserted
ids=1232981683177,1232981683408


so you can get list of ids through {ids} paremeter and then collect attributes for each item as

{ids[i]}_tr_id
{ids[i]}_tr_pid
{ids[i]}_tr_order
{ids[i]}tr_text
{ids[i]}
!nativeeditor_status

response for mass update must contain action tags for all operations ( you can check details here - dhtmlx.com/docs/products/dhtmlxG … aprocessor )


Hi,



i’ve got no beta of data processor so far. Could be, that it is blocked by our mail system. Can you try to send it to



stefan@riedel-seifert.de ?



Thanks in advance,



Stefan

Requested js files sent to provided email.


Hello,



 



the data processor works now as i expected: i get he whole bunch of update information only once. Very good!!!1



The only difficulty is for me, to recognize, if the node was moved to another, or if the label text has changed.



The !nativeeditor_status-information always has the value ‘updated’. If the user has moved a node and changed the label, i will get only one set



of information for this node, so i cannot check what’s the cause. So i must always check against the database if the label text and the parent-id has changed :frowning:.



 



Best regards, Srefan

Locate next line in dhtmlxdataprocessor.js

this.obj.attachEvent(“onDrop”,function(id,id_2,id_3,tree_1,tree_2){
if (tree_1==tree_2)
self.setUpdated(id,true);

and change it as

this.obj.attachEvent(“onDrop”,function(id,id_2,id_3,tree_1,tree_2){
if (tree_1==tree_2)
self.setUpdated(id,true,“moved”);

It will change !nativeeditor_status for rows which was draged to “moved” ( beware that response action@type still must contain “update” as result of operation )
( There are some draw-backs of such solution, so I’m not sure will it be included as part of next version or not )



Ok, that’s a solution, if the user makes only one action on one node during two updates. But in my case, ther can be 4 different situations.only node label changed: status := updated



1) only node dropped: status := moved
2) node dropped, but afterwards label changed: status := moved? -> i cannot recognize without comparing database, that label changed
3) node label changed, but afterwards node dropped: status := moved? -> i cannot recognize without comparing database, that label changed
4) only node label changed: status := updated



Best solution would be, is that all update states will be collected.  Or a status number, which is unique:



1 -> inserted
2 -> changed
4 -> deleted
8 -> dragged



-> 7  means: 1 + 2 + 4 -> noda has been created, changed and afterwards deleted
->11 means: 1 + 2 + 8 -> node has been craeted, changed and dropped



The benefit of this solution is: only label changed is recognizable by status: updated. If status is moved, i have also to update the label. That is better



as in the other case.



Best regards,



Stefan

While proposed solution is really better than existing one , it requires more complicated coding on server side, compared to current approach ( bit mask operations is not common solution for modern web languages )

We will check how such functionality can be incorporated as optional working mode, but default approach for status will stay similar to its current state.