Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Sebastien BROUET on Mar 25, 2008 10:07
open dhtmlx forum
DHtmlXDataProcessor : infinite loop on sendData

Hello,

I used the latest version of DHtmlXDataProcessor.js which solves workaround about XML files not read correctly for local files under IE.

My problem now is that the event handler defined with "myDataProcessor.defineAction()" is called with no end, under IE 6 and Firefox.
In fact the "sendData" method is called repeatedly with no end, the handler seems to be correctly called only once per call of the “sendData” method.

The behaviour is the same whenever my custom action handler finishes with "return true;" or “return false;”. Same for the “setOnCellChanged” handler.


Any help would be greatly appreciated!

Many thanks in advance,

Best regards,
Sebastien BROUET
Answer posted by Support on Mar 25, 2008 10:37
If you are using standard response type ( "insert","update","delete" ) - there must not be any problems, grid automatically remove updated rows from collection of changed data ( please be sure that ction@sid in response contains original row ID )
dp.defineAction("update",function(){
     ...
     return true;
})

If you are using custom response types you need to
a) remove row from collection of changed rows
dp.defineAction("update",function(node){
     ...
    dp.setUpdated(node.getAttribute("sid"),false);
     return false;
})

or

b) stop current processing by setting error flag
dp.defineAction("update",function(){
      ...
     dp.stopOnError=true;
     return false;
})
Answer posted on Mar 26, 2008 06:39

Hello,

Many thanks for the fast and accurate answer.

 I am using custom response.

 The solution a) using "setUpdated(false)" doesn't have any effect, because the row which is updated by my handler does not belong to the array of updated rows holded by the DataProcessor.

 Solution b) which uses “dp.stopOnError=true;” seems to work, yet the sendData is done twice, I believe because my handler is not fast enough.


Could you please tell me if the solution a) you suggested was a mistake or incomplete, or if it should work?


Thanks for your help,

Best regards,

Sebastien BROUET

Answer posted on Mar 26, 2008 06:48
ERRATA : with stopOnError=true, the sendData is called once, it is the handler which is called twice.
It seems that because I have several "action" tags in the XML file, the handler is called as many times as there are "action" tags.
Answer posted by Support on Mar 26, 2008 11:05
>>It seems that because I have several "action" tags in the XML file, the handler is called as many times as there are "action" tags.
It is correct behavior, defined action called against each action tag in response.

>>
Could you please tell me if the solution a) you suggested was a mistake or incomplete, or if it should work?

The main logic of app is next
- row marked as updated ( automatically or by dp.setUpdated )
- if auto update mode enabled
    - for first row in collection of updated rows request to server side generated
           - response from server side received
           - if standard response
                  - remove row from collection of updated rows
           - if custom response
                  - custom code executed
                  - row not removed from collection of updated rows (!!!)
            -  collection of  updated rows  checked and if any row find in it , process repeated

So, as you can see, if  you are using custom response and not remove row from collection of updated - it will be sent to server again and again.

>>because the row which is updated by my handler does not belong to the array of updated rows
I'm not really sure how it can be possible. Because all DP routines operates only with rows marked as updated

As ultimate solution you can just nulify updated rows collection
    dp.updatedRows=[];
it will block any sending attempts for sure.