Categories | Question details Back To List | ||
Loading grid from xml Dear sir, i have the Pro version of grid (v 2.0) and i am working with adobe air. The last one means that i can have access to local disk, reading and writing files. My problem is that when I try to load grid from xml (standard procedure: mygrid.loadXML("the.xml")) and the XML file exists in the same folder with the .html page where the grid is in, everything works fine. But when I try to load grid from xml that exists in another folder e.g. mygrid.loadXML("c:\documents and settings\user\desktop\another.xml") then i get the message "Error load xml - Incorrect xml file". Also have in mind (if that one can help you) that i know where the xml is sitted by a javascript array. Meaning that when i write the xml file, i save the location and the name of the xml in an array. So, the code for initializing the grid is .................... for (var i=0;i<myprod.length;i++) { var thegrid="gridbox"+i mygrid=new dhtmlXGridObject(thegrid) mygrid.setImagePath("codebase/imgs/"); mygrid.enableAutoHeight(true,"400"); mygrid.setSkin("light"); mygrid.init(); mygrid.attachEvent("onEditCell",checkStage); mygrid.enableEditEvents(true,true,true); var n=myprod[i]; mygrid.loadXML(n); //mygrid.loadXML("Types132.xml"); } ................................... Could you please help me? P.S. I have already checked if xml is well formed or not. I have opened it with ff, ie, chrome, opera and safari. All browsers can read it fine! Answer posted by dhxSupport on Apr 07, 2009 08:34 Problem caused by cross domain security - javascript can't operate between documents from different domains. More information about cause of "Incorrect XML" error you can find here http://www.dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Common_Problems_in_Grid.html#grid_art_comprob Answer posted by Trapalis Konstantinos on Apr 08, 2009 01:35 Dear sir, You just confirmed what I was thought for the cause of the problem. So, I have tried some alternative ways to load the grid data, following your documentation and samples. The problem still exists! Case 1: Loading data from a jsarray object My code is: ....... <head><script> function init() { var prodDetArr1=new Array(); prodDetArr1=parent.prodArr1; mygrid = new dhtmlXGridObject('gridbox'); mygrid.setImagePath("codebase/imgs/"); mygrid.objBox.style.overflow="hidden"; mygrid.enableAutoHeight(true,"400"); mygrid.setSkin("light"); mygrid.init(); mygrid.enableEditEvents(true,true,true); mygrid.parse(prodDetArr1,"jsarray"); } window.onload = function () {init();} </script></head> <body> <div> <table> <tr> <td> <div id="gridbox" width="100%" height="50px" style="visibility: visible; background-color:white;overflow:hidden"></div> </td> </tr> </table> </div> </body> I get the following error TypeError: Null value at app:/codebase/grid/dhtmlxgrid.js : 896 at app:/codebase/grid/dhtmlxgrid.js : 896 at app:/codebase/grid/dhtmlxgrid.js : 838 at app:/codebase/grid/dhtmlxgrid.js : 816 at app:/codebase/grid/dhtmlxgrid.js : 784 at app:/codebase/grid/dhtmlxgrid.js : 784 init at ....... Case 2: Loading data from xml island (this is more complicated because I make the XML island on the fly) ................................. <head><script> function makeTheIsland(){ var d=0; var x=1; var prodDetArr1=new Array(); prodDetArr1=parent.prodArr1; var myXML=document.getElementById("island0"); alert("myXML start!"); myXML.innerHTML=""; therows=document.createElement("rows") for (var k=0;k<prodDetArr1.length;k++) { therow=document.createElement("row"); with (therow){ id=prodDetArr1[k][d]; } thecell=document.createElement("cell") var t=prodDetArr1[k][x]; thecell.text=t; therow.appendChild(thecell); therows.appendChild(therow); } myXML.appendChild(therows); alert("myXML is OK!"); } function newGrid(){ alert("Start making the grid"); mygrid = new dhtmlXGridObject('gridbox'); mygrid.setImagePath("codebase/imgs/"); mygrid.enableAutoHeight(true,"400"); mygrid.setSkin("light"); mygrid.init(); mygrid.parse(document.getElementById("island0")); } </script></head> <body onload="makeTheIsland();newGrid();"> <div> <table > <tr> <td> <div id="gridbox" width="100%" height="50px" style="visibility: hidden; background-color:white;overflow:hidden"></div> </td> </tr> </table> </div> <xml id="island0" style="display:none;"></xml> </body> ..and I get the same error! TypeError: Null value at app:/codebase/grid/dhtmlxgrid.js : 896 at app:/codebase/grid/dhtmlxgrid.js : 896 at app:/codebase/grid/dhtmlxgrid.js : 838 at app:/codebase/grid/dhtmlxgrid.js : 816 at app:/codebase/grid/dhtmlxgrid.js : 784 at app:/codebase/grid/dhtmlxgrid.js : 784 init at ....... What I am doing wrong? Thank you in advance for any suggestion.... Answer posted by dhxSupport on Apr 08, 2009 02:11 If you are not specifying number of grid's columns and its width usign setHeader() and setInitWidths() you should have grid configuration into the xml sourse. It seems that your js array and xml island hasn't grid configuration. If you still have this issue please provide us any kind of sample including files which you are using to init grid. |