Hi team,
My Code to add new row in grid.Row is added properly but with error
row.idd=newRowId;if (this.UserData[oldR…erData[newRowId]=this.UserData[oldRowId]
row is undifined
function setAddButtons(rowNum,addColIndex,mygrid,mygridName)
{
for(var i=0;i<rowNum;i++)
{
mygrid.cells2(i,addColIndex).cell.innerHTML=’<INPUT TYPE=“BUTTON” CLASS=“INPUT” onClick=“javascript:addRow(’+mygridName+’,’+i+’,0);” VALUE=“Add” id=“add”’+i+’ />’;
}
var addbutId = ‘add’ + (rowNum-1);
}
function setAddButton(rowIndex,addColIndex,mygrid,mygridName)
{
mygrid.cells2(rowIndex,addColIndex).cell.innerHTML=’<INPUT TYPE=“BUTTON” CLASS=“INPUT” onClick=“javascript:addRow(’+mygridName+’,’+rowIndex+’,0);” VALUE=“Add” id=“add”’+rowIndex+’ />’;
mygrid.selectRow(rowIndex,false,false,false);
}
function addRow(currGrid,rowIndex,parentGuidValue)
{
mygrid=currGrid.gridObj;
var className=currGrid.className;
var parentGuid= null;
if(parentGuidValue){
parentGuid = parentGuidValue;
}
else{
parentGuid=mygrid.cells2(0,mygrid.getColIndexById(“parentGuid”)).getValue();
}
newId = rowIndex+1;
rowIndex=rowIndex+1;
var newUId = mygrid.uid();
mygrid.addRow(newUId,"",rowIndex);
xml_doc=fire(className);
setValue(parentGuid,xml_doc,newId,mygrid);
setAddButton(newId, mygrid.getColIndexById(‘markDelete’)+1, mygrid, currGrid.gridName);
return;
}
function setValue(parentGuid,xml_doc,newId,mygrid)
{
if(xml_doc != null && xml_doc.documentElement != null)
{
var x=xml_doc.documentElement.childNodes;
if(x != null)
{
for(var i=0;i<x.length;i++)
{
if(x[i].nodeName!="#text"){
if(xml_doc.getElementsByTagName(x[i].nodeName)[0].childNodes[0]!=null){
var nodeValue=xml_doc.getElementsByTagName(x[i].nodeName)[0].childNodes[0].nodeValue;
try
{
mygrid.cells2(newId,mygrid.getColIndexById(x[i].nodeName)).setValue(nodeValue);
}
catch(e)
{
alert(x[i].nodeName + e.description);
}
}
}
}
}
}
mygrid.cells2(newId,mygrid.getColIndexById(“parentGuid”)).setValue(parentGuid);
var newUId = mygrid.uid();
var roID=mygrid.getRowIndex(newUId);
mygrid.changeRowId(mygrid.setRowId(roID,newId), mygrid.cells2(newId,mygrid.getColIndexById(“guid”)).getValue());
}
Please, check the remarks to your previous question: dhtmlx.com/docs/products/kb/inde … al&q=10091
If the problem is still actual please provide the complete demo that reproduces it. The provided snippet doesn’t allow to re-create the issue