Add Row In Grid


Hi,

Adding new row in parent grid by calling addRow() method but the focus is set on previous row.

and on select of new row created in parent grid child grid is created with new row added for that parent row.

but on every time click on new parent row child row is created i checked



function parentGrid_onRowClick(rowId,cellId,value){

var parentId= parentGrid.getCellValue(rowId,‘parId’);

var colIndex = childgrd.getColIndexById(‘parentId’);



childgrd.gridObj.filterBy(colIndex,parentId, false);



if(childgrd.gridObj.getRowsNum() ==0){

addRow(childgrdId,0,parentId);



childgrd.gridObj._srowsCol=deg_valuesDEG.gridObj._f_rowsBuffer=deg_valuesDEG.gridObj._srowsBuf=null;

        childgrd.gridObj.filterBy(colIndex,parentGuid, false);

}





}

But getRowsNum() returns 0 for every time even child row is present in child grid.



function addRow(currGrid,rowIndex,parentGuidValue)

{    



    mygrid=currGrid.gridObj;

    var className=currGrid.className;

    var parentGuid= null;



//New row (newId) is unique in grid

    var newId = rowIndex+1;



    rowIndex=rowIndex+1;

    mygrid.addRow(newId,"",rowIndex);



    var rowId = mygrid.getRowId(rowIndex);



    

    if(parentGuidValue)

        parentGuid = parentGuidValue;

    else

        parentGuid=mygrid.cells2(newId,mygrid.getColIndexById(“guid”)).getValue();



    



    xml_doc=fire(className);

//Setting value in grid

    setValue(parentGuid,xml_doc,newId,mygrid);

    mygrid.selectRowById(newId);



//Call button function

    setAddButton(rowIndex, mygrid.getColIndexById(‘markDelete’)+1, mygrid, currGrid.gridName);

    

    return;

}





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+’ />’;

        



        

}







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);

    



    

}

Please provide us full working sample where we can reproduce this issue including all files which you are using to initialize grid.