Update works, BUT insert and delete break the server Sync

Hello,

update action works as expected; But when I do either delete or insert that operation is executed correctly, BUT after that communication with server stops?! Response methods are same for update, insert and delete. In debug window it reaches:

row 6 marked [deleted,valid]
 Initiating data sending for all rows 

And nothing happens further. Actions on the grid are still possible but no syncing

Doing sync via:
Sync Light

How sync properly even after insert or delete operations?

Regards

Make sure if server side returns correct response on “insert” and “update” operations

Thanks Olga,

Yes, server response(s) are correct

Code is improved version of:
viewtopic.php?f=2&t=17895

Any further idea?

Regards

Unfortuantely we cannot reproduce this issue locally. Please check example here dhtmlx.com/docs/products/dht … _init.html

Hi,

Seems to work now: extended the response callback method for insert/delete.
So, for update it’s enough to :

mygrid.clearAll();				
mygrid.load("http://localhost:8080/...","json");

but for insert/delete grid needs to be reinitialized

mygrid.clearAll();				
mygrid.load("http://localhost:8080/...","json");

dp = new dataProcessor("http://localhost:8080/..." );
dp.setTransactionMode("GET", true);
dp.setUpdateMode("off");
dp.defineAction("updated", responseUpdated);
dp.defineAction("inserted", responseHandle);
dp.defineAction("deleted", responseHandle);
dp.defineAction("error", responseError);
dp.init(mygrid);'

Regards

After more detailed testing it turns out that some problems still persist: grid stops working.
Can you share code for proper reinitialization of grid and dataprocessor? Btw, I’m sending all modified data to the server (NOT row by row)
docs.dhtmlx.com/doku.php?id=dhtm … aprocessor

Regards

Can you share code for proper reinitialization of grid and dataprocessor?
You can find such example at your dhtmlxGrid package dhtmlxGrid\samples\04_dataprocessor\

Have 10 rows in my grid;
When I erase 1 of the rows it turns out that it had sid=6 and tid=10 (value from DB) in response;

Right after that when I insert a row and hard-code sid=6 and tid=10 -it works!
BUT values of sid and tid in practice are different, for assigned by:
-grid it’s 1302803179371
-DB it’s 10

For type i use inserted, updated, deleted and I implemented appropriate response methods

How to generate proper sid? Response is dependent on that value and, as it’s currently incorrect, breaks further functionality of the grid.
In this case 1302803179371 != 6 but should be

Grid expects following responce from the server side:

<data> <action type="some" sid="some" tid="some" /> </data>

Where
type - the type of the operation (it may be “insert”, “update”, “delete”);
sid - the original id of the row (the same as gr_id);
tid - the id of the row after the operation (may be the same as gr_id, or some different one - it can be used during a new row adding, when a temporary id created on the client side is replaced with the id taken from the DB or by any other business rule).

You can regenerate proper id when you adding row:

mygrid.addRow(“proper_id”,"");

How will proper_id look fully depends on your business rule

Thanks Olga,

Seems that grid is picky about proper proper_id. How to make it same as sid?

My add function look like:

function addRow(){'
// var newId = (new Date()).valueOf();
   var newId = mygrid.getRowsNum()+1;	
   mygrid.addRow(newId,"",mygrid.getRowsNum());
   mygrid.selectRow(mygrid.getRowIndex(newId),false,false,true);		
};

After inserting there comes the response, but grid dies after. See last line of the log, please

Current mode: off
 Log:
 row 8 marked [inserted,valid]
 row 8 marked [updated,valid]
 row 8 marked [updated,valid]
 row 8 marked [updated,valid]
 row 8 marked [updated,valid]
 row 8 marked [updated,valid]
 row 8 marked [updated,valid]
 row 8 marked [updated,valid]
 row 8 marked [updated,valid]
 row 8 marked [updated,valid]
 row 8 marked [updated,valid]
 row 8 marked [updated,valid]
 Initiating data sending for all rows
 Sending all data at once
 Server url: http://localhost:8080/JavaServlet/parameter1/ parameters
 Server response received details
 Action: inserted SID:8 TID:10
 row 6 marked [updated,valid]

How comes that

row 6 marked [updated,valid] and not
row 8 marked [updated,valid]
or
row 10 marked [updated,valid]
?
Where is that value 6 came from?
When response from server is hard-coded to that value, grid remains alive!

How to initiate

var newId = 

to that value properly? So need to be sid

Regards

Just to clarify, after INSERT i do an UPDATE on same row and last line of the log is for that action; When want to sync with server again (to submit that update action) -it doesn’t work

Regards