Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Michael on Dec 03, 2008 08:17
open dhtmlx forum
dataProcessor - defineAction() error handler

I am able to correctly associate a defineAction() error handler for my dataprocessor. However, when I handle my error within my handler function in javascript, I am having problems.

Basically what I am doing is the following.

1. I have a folder tree
2. If a user tries to delete a folder tree that has files associated to it, I want to return a nice message telling them they cannot delete because it has files associated to it.
3. I set my defineAction() function to handler the return action.
4. I can return the action and present my message, but then I get the following error after a few seconds.

Error type: loadXML
Description: incorrect XML

Why am I getting this message?
Answer posted by Support on Dec 04, 2008 01:50
There are two things to check
a) are you using custom action type , or just extend default delete option? In second case you need to be sure to return false from event handler, to prevent defautl logic execution. 
b) beware that while code was not deleted on server side , the item still marked as updated on client side and will be send to server again with the next update. You may use|   
       dp.setUpdated(id,false)
to remove such mark.

You can try to add attached js file on your page, it will add debug console for the dataprocessor. 
Attachments (1)
Answer posted by Michael on Dec 04, 2008 07:07

I implemented your suggestion b.).  This seems to stop the Error Type: loadXML error but the tree node remains with a "line" drawn through the node.   And if I click that node again the nodes are deleted (not on the server side because of my validation) but only on the client side. 

Am I implementing this correctly?  I am following the example in the dhtmlDataProcessor "Guide Section" under the title "Custom server side responses".

below is my handler function. oDataProcessor is declared global and is instantiated upon body onLoad().

function folderMaintenanceDeleteErrorHandler(node)
{
   
    document.getElementById("spanMessageHeader").innerHTML = "Cannot delete - The folder or one of its subfolders contains file(s).";
    document.getElementById("spanMessageHeader").style.color = "red";
    oDataProcessor.setUpdated(node.getAttribute("sid"),false);

    return false;
}

My xml looks like this, with variables being populated as follows:

$newId = $_GET["tr_id"];
$action = "ERROR_CANNOT_DELETE_FOLDER";

<!-- response xml -->
<data>
        <action type='<?=$action?>' sid='<?=$_GET["tr_id"]?>' tid='<?=$newId?>'></action>
</data>

Answer posted by Support on Dec 04, 2008 10:06
The code which you are using is correct, but not enough, try to extend it as

var id=node.getAttribute("sid");
oDataProcessor.setUpdated(id,false);
tree.setUserData(id,"!nativeeditor_status","");
tree.setItemStyle(id,"text-decoration : none;");


 
Answer posted by Michael on Dec 04, 2008 10:57
That did it.  Thank you!