DHTMLx Grid producing error dynamically


I am using following function:



function changeCountry(country)

{

    rLength="<?php echo get_configRates(); ?>";

    document.getElementById(“maintable”).innerHTML="";

    for(var i=0;i<rLength;i++)

    {

        var div="<div id=“gridbox_”+i+"" width=“100%” height=“250px” style=“background-color:white;overflow:hidden”>";

        var divName=“gridbox_”+i;

        document.getElementById(“maintable”).innerHTML+=div;

        mygrid = new dhtmlXGridObject(divName);

        mygrid.setImagePath(“externalfiles/CodeBase/imgs/”);

        mygrid.loadXML(“common/libs/x_dbutil.php?no=”+i+"&function=getRates&val=CDo/Smpqamq6gKRZ57fm4sgyTIAqVftN1zg4nudHnhgHvxd6rQ==&country="+country);

    }

}



This will load div as well as grid dynamically. Every thing in xml is right. The file is fine. But i get following error



Error: parent is null

Source File: localhost/Calling%20Cards/Fline/ … /dhtmlx.js

Line: 1129

This error is not related with dhtmxGrid initialization. Such error can return incorrect “attachHeader” or “attachFooter” methods. Could you please provide us sample of xml which you are using?

Following is the xml




Price
Rate
Minutes



5
0.0240
208



10
0.0240
417



15
0.0240
625



20
0.0240
833



25
0.0240
1042


i separated the loop where div was created dynamically and initialization of dhtmlx grid and every thing is working fine

function changeCountry(country)
{
   rLength="<?php echo get_configRates(); ?>";

    document.getElementById(“maintable”).innerHTML="";
    var div="";
    for(var i=0;i<rLength;i++)
    {
        div+="<div id=“gridbox_”+i+""   style=“height:200px;width:100%;background-color:white;overflow:hidden”>";
                
    }
    document.getElementById(“maintable”).innerHTML=div;
    for(i=0;i<rLength;i++)
    {
    mygrid = new dhtmlXGridObject(“gridbox_”+i);
        mygrid.setImagePath(“externalfiles/CodeBase/imgs/”);

        mygrid.loadXML(“common/libs/x_dbutil.php?no=”+i+"&function=getRates&val=CDo/Smpqamq6gKRZ57fm4sgyTIAqVftN1zg4nudHnhgHvxd6rQ==&country="+country);
    }
}