Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Agata Malczewska on Jun 08, 2009 01:07
open dhtmlx forum
setVerificator - data sending not blocked

The documentation says that if any value was denied during validation then data sending will be blocked. I have noticed that data sending is blocked only for one row and not all updated - it means, if I edit 2 rows: in one data are OK (setVerificator returns true) and in another one data are invalid (setVerificator returns false), then the data which are OK are send to server and only the invalid data is blocked (I use setUpdateMode("off")). Is such behaviour proper? From the documentation I understood, that all data (from all updated rows) should be blocked in case any value (in any row) is denied. If it is proper, how can I block the entire update?

This is how I use the verificator:
myDataProcessor.setVerificator(1, checkIfNotNull);

function checkIfNotNull(value, rowId, colIdx) {
if (value.toString()._dhx_trim()=="") {
showError("Wrong data!");
return false;
}
else
return true;
}
Answer posted by Support on Jun 08, 2009 02:03
Behavior depends on used data sending mode. 

It can be "separate updates" ( default ) and "send-all-at-once"
In first case each row sent separately, so blocking one row will not block other updates
In case of "send-all-at-once" mode - all rows sent as single request, so error in one row will block all from sending.


You can enable "send-all-at-once" mode, by using 
           dp.setTransactionMode("POST",true);

Answer posted by Agata Malczewska on Jun 08, 2009 02:28
Well, then in my case it works exactly in the opposite manner ;)
I do have 'send-all-at-once' mode set: myDataProcessor.setTransactionMode("POST",true);
and an error blocks only the row in which it occured - the rest is sent to server...
Answer posted by Support on Jun 08, 2009 03:28
Which version of dhtmlx package are you using?

Please try to add the next code to dataprocessor's init

dp.attachEvent("onBeforeUpdate",function(id,message){
          var allow =  true;
          for (var a in this._invalid)
               if (this._invalid[a]) allow=false;

          return allow;
});

With such code, dataprocessor will not send any data , while there is some element, marked as invalid.
Answer posted on Jun 08, 2009 03:47
Thank you very much! It works with the event attached! :)
Btw. I'm using v.2.1 build 90226.