Categories | Question details Back To List | ||
TreeGrid Seralize method with onlyChanged data Hello, I am using the Pro version and we are having an issue with the serialization of a TreeGrid (for Grid it works fine) while sending only the modified data. There is a method for the grid called setSerializationLevel which arguments are: userData - enable/disable user data serialization selectedAttr - include 'selected' row's attribute in result XML config - serialize grid configuration (only information about grid structure) changedAttr - include 'changed' cell's attribute in result XML onlyChanged - include only changed rows in result XML asCDATA - output cell values as CDATA sections (prevent invalid XML). When the method serialize() is called on the TreeGrid, if "onlyChanged" is selected as true, the Xml should be constructed only with the information changed in the TreeGrid.Am I correct? For each cell of a given row, when its value is changed, it inserts a new attribute on the cell called changed (changed='1'). Then, when serializing to an Xml, it possibly iterates through the rows of the TreeGrid and if any cell of a given row is changed, this row is serialized. The issue comes while modifying / inserting a row as a child to another in the TreeGrid. The "changed" attribute of the cell of the given row is correctly inserted, but the row is not been serialized. If it's father/s changes also, the row is being serialized. Probably the serialize method is iterating through the rows, and when it finds a father of "n" rows childs which has no cells changed, it doesn't iterate thorugh and serialize (if necessary) its childs. Could this be a bug? Answer posted by Alex (support) on Nov 11, 2009 08:49 Hello, if only child node was changed, the parent as well as the whole branch won't be serialized. This is the expected behaviour. You can try to use the following approach to mark the parent row as changed when its child edited: grid.attachEvent("onEditCell",function(stage,id,index){
Answer posted by Andres on Nov 11, 2009 10:21 Alex, Thanks for your response. I used the approach you told me recently, adding a recursive way like this.(my tree has many levels) // Set the row and the parents of a given row, as changed function setChangedParents(rowId){ setRowChanged(rowId); var _parent = myTreeGrid.getParentId(rowId) //If the parent exists if(_parent != 0){ setChangedParents(_parent); } } //Sets every Cell of a given Row as changed function setRowChanged(rowId){ for(var _i = 0; _i < myTreeGrid.getColumnCount(); _i++){ myTreeGrid.cells(rowId,_i).cell.wasChanged=true; } } Thanks for everything Andres |