Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by rtabassum on Jan 25, 2009 23:32
open dhtmlx forum
Dhtmlx Layout Problems,Cell Expand and Collapse showing parent.dhxLayout is undefined

Hi i am using dhtmlx layout and i am unable to perform collapse and expand of cells it gives me errors i tried the demo mailed by you people its working there but i dont no whats wrong in my files can you please go through an dreply me back soon.

My main file where there is a div object and iframes (to this div object the layout is attached and iframes attached to each cell of layout).

index.html

<head>

<script type="text/javascript" language="JAVASCRIPT" src="../src/jsp/StoFewa.js"></script>

</head>

<body onload="loadAccordSF();">

<div id='logodiv1'><label id='pname1'><FONT SIZE="4" COLOR="black" face="cursive"><B>BAD DEBT RECOVERY</B></FONT></label>
</div>
<DIV ID="maindiv">


<div id='accorddiv'></div>

<iframe id='iframe2'> </iframe>
<iframe id='iframe3'> </iframe>
<iframe id='iframe4'> </iframe>


</DIV>

StoFewa.js

function loadAccordSF()
{

 
  parent.document.getElementById('iframe3').style.visibility="hidden";
 parent.document.getElementById('iframe4').style.visibility="hidden";
 
 
    var dhxLayout = new dhtmlXLayoutObject("maindiv", "4E", "dhx_blue"); 
    dhxLayout.setAutoSize(200,200);

    dhxLayout.cells("a").hideHeader();
 
    dhxLayout.cells("a").setWidth(206);
    dhxLayout.cells("a").setText("SELECT");
    dhxLayout.cells("b").setText("STO BATCH PREPARATION");
    dhxLayout.cells("c").setText("STO BATCH PREPARATION II");
    dhxLayout.cells("d").setText("STO BATCH CONFIRMATION");
 
 
    var dhxAccord = dhxLayout.cells("a").attachAccordion();
    dhxAccord.addItem("a1", "STO");
    dhxAccord.addItem("a2", "FEWA");
    dhxAccord.addItem("a3", "60 Day");
    dhxAccord.cells("a1").open();

      dhxLayout.cells("b").attachObject("iframe2");
      dhxLayout.cells("c").attachObject("iframe3");
      dhxLayout.cells("d").attachObject("iframe4");

               dhxLayout.cells("c").collapse();
               dhxLayout.cells("d").collapse();
 
 
        var tree = dhxAccord.cells("a1").attachTree();
        tree.setImagePath("../dhtmlxTree/codebase/imgs/csh_yellowbooks/");
        tree.enableTreeLines(true);
        tree.setImageArrays("plus4","","","","plus4.gif");
        tree.setImageArrays("minus4","","","","minus4.gif");
        tree.setStdImages("folderClosed.gif","folderOpen.gif","folderClosed.gif");
  

  //tree.enableTreeLines(true);
  tree.enableHighlighting(true);
        tree.loadXML("../tree.xml");

  
  
  tree.attachEvent("onClick",function(item_id){
     if(item_id=="stopre"){
  tree.openItem("stopre");
  tree.setItemImage2("stopre","folderOpen.gif","folderClosed.gif","folderClosed.gif");
  tree.setItemImage("stopre","folderOpen.gif","folderClosed.gif");
  tree.setItemColor("stopre","blue","blue");
  tree.setItemStyle("stopre","font-weight:bold;font-size:11;font-family:arial");
  tree.selectItem("stopre");
  tree.setItemImage2("stoconf","folderClosed.gif","folderClosed.gif","folderClosed.gif");
  tree.setItemImage("stoconf","folderClosed.gif","folderClosed.gif");
  tree.setItemColor("stoconf","black","black");
  tree.setItemStyle("stoconf","font-weight:normal;font-size:11;font-family:arial");
  tree.setItemImage2("stoaccp","folderClosed.gif","folderClosed.gif","folderClosed.gif");
  tree.setItemImage("stoaccp","folderClosed.gif","folderClosed.gif");
  tree.setItemColor("stoaccp","black","black");
  tree.setItemStyle("stoaccp","font-weight:normal;font-size:11;font-family:arial");
  tree.setItemImage2("stofeed","folderClosed.gif","folderClosed.gif","folderClosed.gif");
  tree.setItemImage("stofeed","folderClosed.gif","folderClosed.gif");
  tree.setItemColor("stofeed","black","black");
  tree.setItemStyle("stofeed","font-weight:normal;font-size:11;font-family:arial");

 
    document.getElementById('iframe2').src="JSP2.jsp"; //panel b get populated with JSP2.jsp file which conatins buttons
 
  
   }

    


});

  
}

  function batchPreparation()
{

parent.dhxLayout.cells("c").expand();

}

 

 

 

JSP2.jsp

 <script type="text/javascript" language="JAVASCRIPT" src="../src/jsp/StoFewa.js"></script>
<A class="button" HREF="javascript:batchPreparation()" title="Batch Preparation" ID='batchpreparation'><span class='bcolor'>Batch Prep</span></A>

 

The Error what i am getting here is

parent.dhxLayout is undefined
batchPreparation()JSP2.jsp(line 172)
javascript:batchPreparation()()()javascri...aration() (line 1)
parent.dhxLayout.cells("c").expand();

 

 


 

Answer posted by Support on Jan 26, 2009 06:00
You have defined dhxLayout as variable with local visibility, so it not accessible from external scripts.
Can be fixed as

var dhxLayout;
function loadAccordSF()
{

 
  parent.document.getElementById('iframe3').style.visibility="hidden";
 parent.document.getElementById('iframe4').style.visibility="hidden";
 
 
  dhxLayout = new dhtmlXLayoutObject("maindiv", "4E", "dhx_blue");