Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Hans on May 18, 2008 15:38
open dhtmlx forum
Get changed, deleted, inserted rows in grid - best approach?

Hi!
What is in your opinion is the best approach for keeping track of changed, inserted and deleted rows in a grid, without using the dataProcessor?

Rght now I do this:
- A couple of global variables store ID's and row indexes of changed, inserted and deleted rows.
- User makes changes and hits Save-button
- The serialize function gets all XML which is sent to the server, along with the variables.
- On the server I loop thrugh all rows and make proper changes, deletes and inserts according to the affected rows
- ID's for inserted rows are sent back to the client and updated in the grid
- Global vars are reset

It is a bit cumbersome, any other approch you recommend (without the dataProcessor)?
It seems like getChangedRows doesn't return new rows.

Thanks!
Answer posted by Support on May 19, 2008 06:40

If by some reason you can't use dataprocessor, you can check "form integration" functionality, which do similar task ( it maintains the list of deleted|added rows and changed cells)

http://dhtmlx.com/docs/products/dhtmlxGrid/samples/interaction_other_components/pro_form.html?un=1211205087000
http://dhtmlx.com/docs/products/dhtmlxGrid/doc/new_1_3.html#grid_htmlform

The only other alternative to dataprocessor and form integration is the custom solution. Basically it is pretty simple on client side - onRowAdded and onBeforeRowDeleted events can be used to monitor row adding|deleting and serialization of changed rows used to serilaize only updated rows. The data on client side can be fully reloaded ( grid.clearAll, grid.loadXML ) to prevent any additional code for ID updating. ( Also you can define additional properties of grid object, to not use global vars )

>>It seems like getChangedRows doesn't return new rows
getChangedRows will return only rows which is edit by user, you can mark any row as changed by

grid.cells(id,0).cell.wasChanged=true

 

Is there some special reason why dataprocessor can't be used in your case? ( it must simplify data saving implementation )