Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Atanas Koev on Sep 09, 2008 04:54
open dhtmlx forum
dhtmlxGrid with dataProcessor


Hi,

I am using dhtmlxGrid with dataProcessor. When sendData is called the dataProcessor sends XMLHttpRequest to the serverProcessorUrl with necessary data in the query string. This works fine.
My scenario is slightly different. I have a javascript proxy of a webservice. The calls to the webmethods are wrapped in javascript functions.
Is there a way to call my custom function instead of the standard sendData? Is there a way to customize the behavior of the sendData method, or to handle some event and do the actual update in the event handler? I tried to use OnBeforeUpdate for that purpose but if the handler of this event returns false the dataProcessor does not process the rest of the rows.
In relation with above questions what is the easiest way to serialize as xml only the updatedRows of the grid?

I'll be gratefull uf you can give me some ideas. Thanks in advance.

Atanas
Answer posted by Support on Sep 09, 2008 05:20
>> Is there a way to customize the behavior of the sendData method
The solution with onBeforeUpdate is a correct one
    dp.setOnBeforeUpdateHandler(function(id,status){
       .. any custom code here ...
      dp.setUpdated(id,false); //mark row as updated
      dp.sendData(); // process any other row , which is not saved yet
      return false;
     });

Technically you may just use updatedRows collection , which stores IDs of updated rows , and  "!nativeeditor_status" userdata of row, which stores status of row, instead of using sendData method. 

>>what is the easiest way to serialize as xml only the updatedRows of the grid
a) grid can serialize row's with changed data
    grid.setSerializationLevel(false,false,false,false,true);
    var xml = grid.serialize()

b) you can loop through updatedRows and use 
    var xml = grid._serializeRow(grid.getRowById(dp.updatedRows[i]));