Categories | Question details Back To List | ||
Grid Add Row function Hi team, I am adding a new row in a grid by Add button row is added properly but the focus is set on the previous row. My Code is function setAddButton(rowIndex,addColIndex,mygrid,mygridName) { mygrid.cells2(rowIndex,addColIndex).cell.innerHTML='<INPUT TYPE="BUTTON" CLASS="INPUT" onClick="javascript:addRow('+mygridName+','+rowIndex+');" VALUE="Add" id="add"'+rowIndex+' />'; mygrid.selectRow(rowIndex,false,true,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; mygrid.addRow(newId,"",rowIndex); xml_doc=fire(className); setValue(parentGuid,xml_doc,newId,mygrid); setAddButton(rowIndex, 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); //mygrid.selectCell(mygrid.getRowIndex(newId),0,false,false,true); mygrid.changeRowId(newId, mygrid.cells2(newId,mygrid.getColIndexById("guid")).getValue()); } Answer posted by Alex (support) on Jun 19, 2009 04:53 Hello, please, check that ids are grid are unique. And selectCell is called with desired index |