DHTMLXGRID serialize issue

DHTMLXGRID serialize issue

Hi ,
I am able to get the data from the backend successfully in dhtmlxgrid.
Then I have added a new row using
function addRow(init_values)
{

var rowId = (new Date()).valueOf();
var cnt = mygrid.getRowIndex(rowId);
 var newId = (new Date()).valueOf();

mygrid.addRow(newId,"",cnt+1);
mygrid.selectRow(mygrid.getRowIndex(newId),false,false,true);
}
Also,I am able to add the values in the new row added.
But while serializing the grid I am not getting the desired xml.
I am only getting the first row fetched from the backend as the serialized xml and not the newly added row from UI.I have debugged the javascript and found that “temp” and “out” variable returned only the first row of the grid and not the newly added.

What could be the issue ?Here is how the grid is initialized.

var mygrid = null;
mygrid = new dhtmlXGridObject(‘mygrid’);
var grid_get = “/url.do?
var header_l1 = “h1,h2.h3,h4,h5,h6,h7”;
var width_l1 = “200,200,160,160,160,200,160”;
var align_l1 =“center,center,center,center,center,center,center”;
var type_l1 = “ed,ed,ed,ed,ed,ed,ed”;
var sorts_l1 =“str,str,str,str,str,str,str”;
mygrid.imgURL =”/dhtmlx/imgs/";
var headerStyles=[ “color:#000000;”,
“color:#000000;”,
“color:#000000;”,
“color:#000000;”,
“color:#000000;”,
“color:#000000;”,
“color:#000000;” ];
mygrid.setHeader(header_l1,"#cspan", headerStyles);
mygrid.setInitWidths(width_l1);
mygrid.setColAlign(align_l1);
mygrid.setColTypes(type_l1);
mygrid.enableMultiline(true);

var pp_header = “background-color:#C8C8C8;color:white;font-family:Tahoma Regular;”;
var pp_grid = “height:auto;”;
var pp_selCell = “background-color:#B5C7E7;font-family:Tahoma Regular;”;
var pp_selRow = “background-color:#B5C7E7;font-family:Tahoma Regular;”;
mygrid.setStyle(pp_header, pp_grid,pp_selCell, pp_selRow);
mygrid.setSizes();
mygrid.enableAlterCss(“even”,“uneven”);
mygrid.enableCollSpan(true);

mygrid.init();

mygrid.loadXML(grid_get);
mygrid.attachEvent(“onCellChanged”,doOncellChanged);
dhtmlxError.catchError(“LoadXML”, myErrorHandler);

Any help would be much appreciated.
Waiting for your reply as I am blocked totally on this.

Thanks & Regards,
Lalit

While code looks correct, you can try to change

mygrid.addRow(newId,"",cnt+1);

as

mygrid.addRow(newId,"",-1);

It will add the row at last position, while manual index calculation can have some caveats