AddRow() but prevent DataProcessor executing

I have a treeGrid onto which I drop objects and where my dataProcessor updates the backend database. I’m also trying to add a child objects using addRow() but, in these instances, I don’t want the new rows to be added to the backend database. How can I prevent the dataProcessor from executing (at known levels of my tree)?

Here’s where I am. Code snippet:


dp = new dataProcessor(“update_option.php”);
dp.enableDataNames(true);
dp.init(option_grid);

dp.setOnBeforeUpdateHandler(function(id, type) {
alert (“In setOnBeforeUpdateHandler”);
if (type==“inserted”){
// some processing

}

return true;
});

dp.setOnAfterUpdate(function(id, type, new_id) {
alert (“In setOnAfterUpdate”);
if (type==“insert”){
// some processing

if (option_grid.getLevel(new_id) == “3” && option_grid.getUserData(new_id, “procType”) == “P”) {
var y=0;
var z=(new Date()).valueOf()+y;
//add first child row
option_grid.addRow(z,[‘new_name_1’,’’,’’,’’,’’,’’,’’,’’,’’],0,new_id);
dp.afterUpdateCallback(z,z,“insert”);
y++;
z=(new Date()).valueOf()+y;
//add second child row
option_grid.addRow(z,[‘new_name_2’,’’,’’,’’,’’,’’,’’,’’,’’],0,new_id);
dp.afterUpdateCallback(z,z,“insert”);
}
alert (“Finished adding child nodes to the the new_id”);
}
return true;
});

So what I notice is that adding a child node within setOnAfterUpdate actually retriggers setOnBeforeUpdateHandler. I don’t actually want the manually added rows to also be added to the backend database. Is there a way to stop setOnBeforeUpdateHandler being re-triggered? The re-triggering therefore causes the incorrect parent id (i.e. new_id) to be used when adding the second row.

Thanks

DataProcessor tracks the event of grid, so it will react on all actions.
You can to use next command sequence to block double-adding

[code]dp.setOnAfterUpdate(function(id, type, new_id) {

dp.setUpdateMode(“off”);

option_grid.addRow(z,[‘new_name_1’,’’,’’,’’,’’,’’,’’,’’,’’],0,new_id);

dp.setUpdated(z, false);
dp.setUpdateMode(“cell”);
[/code]

Above code will disable auto-update, remove update mark from the newly added row , and re-enable auto-updates

I’ve implemented the following code, as suggested, which is preventing the dp from executing, as desired.

[code]dp.setOnAfterUpdate(function(id, type, new_id) {

dp.setUpdateMode(“off”);

option_grid.addRow(z,[‘new_name_1’,’’,’’,’’,’’,’’,’’,’’,’’],0,new_id);

dp.setUpdated(z, false);
dp.setUpdateMode(“cell”);[/code]
However, if I then edit a cell in the newly added row, the value of “type” in the triggered setOnBeforeUpdateHandler(function(id,type) {…}) is “inserted”. I’m expecting it to be “updated”!

I’ve noted that the newly added row’s UserData has a !nativeeditor_status with a value of “inserted”. Is this value being carried through to “type” when I edit the cell? Do I need to add something after the dp.setUpdateMode(“cell”)?