Problem about grid's addrow

My program is, orderGrid shows product orders, when a row is clicked, productGrid displays all product lists of that order. User may drag product(s) from productGrid to another grid called issueGrid. There’s no problem using gridtogrid to drag item from productGrid to issueGrid. But I want to implement such: drag a item from orderGrid to issueGrid and all items showing in productGrid will be added to issueGrid. At first I do this using grid.serialize and find it will clear issueGrid. Then I have to write code using addRow() :

... $config->setHeader ("ProductModel,Quantity,UnitPrice,TotalPrice,LeadTime"); $config->setColTypes ("rotxt,edn,price,ron[=c1*c2],coro"); // configuration of issueGrid ... this.orderGrid.attachEvent ("onDrop",function(sId,tId,dId,sgrid,tgrid,sCol,tCol){ var cell,i,val,tcId,cIdx; // sgrid is orderGrid, sgrid.childObj.grid is productGrid sgrid.childObj.grid.forEachRow (function (rowId){ cell = ''; for (i=0;i<tgrid.getColumnsNum();i++) { if (tgrid.getColType (i) === 'math') { val = null; } else { tcId = tgrid.getColumnId (i); cIdx = sgrid.childObj.grid.getColIndexById (tcId); if (typeof(cIdx) != 'undefined') val = sgrid.childObj.grid.cellById (rowId,cIdx).getValue(); else val = null; } if (val) cell = cell + val; cell = cell + ','; } tgrid.addRow ((new Date()).valueOf(),cell); }); })
No trouble when rows is few. But when there are many rows (9 rows in this pic), strange thing happened. Column 3 (=c1*c2) may work wrong.


When I change quantity of ‘SEC99AD-36D’, TotalPrice of ‘RS-1140-0000’ changed too. If ‘RS-1140-0000’ is selected, it can’t be deselected.
It seems addrow() is Asynchronous and runs faster (slower?) than main procedure.

Sorry, found the point. I set the wrong id when configuring $conn->render_sql ($sql,$id,$text,$extra)