Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by John-Olav Hoddevik on Apr 28, 2008 05:19
open dhtmlx forum
Deleterow confirm message

I want to add a confirm-message before deleting a row. I do this by using mygrid.setOnBeforeRowDeletedHandler.

The message works, but if my handler return false, so that the row is not deleted, then the text in the row still has the strike-trought style.
Answer posted by Support on Apr 28, 2008 05:48
This is result of dataprocessor work , it handles onBeforeRowDeletedevent as well so returning false doesn't affect it , you can try to use next code

grid.attachEvent("onBeforeRowDeleted",function(id){
    if (!confirm(some)){
       window.setTimeout(function(){   // to resolve timing issues
           dataproc.setUpdated(id,false);   //remove update mark
            grid.setRowTextStyle(id,"text-decoration : none;");
       },1);
       return false;
    }
    return true;
})
Answer posted by John-Olav Hoddevik on Apr 28, 2008 06:14
This is working expect for one small detail. The confirmation message is triggered twice...
Answer posted by Support on Apr 28, 2008 07:43
Yep, it possible because of dataprocessor ( the second time it generated when delete confirmation retrieved from server )
You can update code as

grid.attachEvent("onBeforeRowDeleted",function(id){
    if (grid.getUserData(id,"!nativeeditor_status")=="true_deleted") return true;
Answer posted by John-Olav Hoddevik on Apr 29, 2008 00:44
Now the row is deleted without any questions. Here is my code:
mygrid.attachEvent("onBeforeRowDeleted",function(id)
   {
       if (grid.getUserData(id,"!nativeeditor_status")=="true_deleted") return true;
        if (!confirm("Er du sikker på at du vil slette denne bestillingen?"))
        {
            window.setTimeout(function(){   // to resolve timing issues
             myDataProcessor.setUpdated(id,false);   //remove update mark
             mygrid.setRowTextStyle(id,"text-decoration : none;");
               },1);
       return false;
         }
         
    return true;
     })