Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by bibu on Jun 23, 2008 15:54
open dhtmlx forum
The corresponding JSON file for the XML file

Hey friends

I would like to know what is the exact structural pattern to be maintained if pass a JSON file instead of an XML file

for Example

This is my XML File(sample.xml);

<?xml version="1.0"?>
<rows>
<head>
<column width="220" align="left" type="tree">Category</column>
<column width="25" align="center" type="ro">*</column>
<column width="24" align="center" type="ro">0-1</column>
<column width="24" align="center" type="ro">2</column>


<settings>
<colwidth>px</colwidth>
</settings>

</head>
<row id="Business/Services">
<cell image="folder.gif">Business/Services</cell>
<cell style="background-color:#336633;color:#336633;">1</cell>
<cell style="background-color:#336633;color:#336633;">1</cell>
<cell style="background-color:#336633;color:#336633;">1</cell>

<row id="1">
<cell>Stock Trading</cell>
<cell style="background-color:#336633;color:#336633;">1</cell>
<cell style="background-color:#336633;color:#336633;">1</cell>
<cell style="background-color:#336633;color:#336633;">1</cell>


</row>
<row id="2">
<cell>Job Search</cell>
<cell style="background-color:#336633;color:#336633;">1</cell>
<cell style="background-color:#336633;color:#336633;">1</cell>
<cell style="background-color:#336633;color:#336633;">1</cell>

</row>
<row id="3">
<cell>Finance/Banking</cell>
<cell style="background-color:#336633;color:#336633;">1</cell>
<cell style="background-color:#336633;color:#336633;">1</cell>
<cell style="background-color:#336633;color:#336633;">1</cell>

</row>
<row id="4">
<cell>Business</cell>
<cell style="background-color:#336633;color:#336633;">1</cell>
<cell style="background-color:#336633;color:#336633;">1</cell>
<cell style="background-color:#336633;color:#336633;">1</cell>


</row>
</row>

</rows>


and i am passing it through the following code

<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxgrid.css">
    <script src="../../codebase/dhtmlxcommon.js"></script>
    <script src="../../codebase/dhtmlxgrid.js"></script>        
    <script src="../../codebase/dhtmlxgridcell.js"></script>    
    <script src="../../codebase/dhtmlxtreegrid.js"></script>    


gridbox = new dhtmlXGridObject('gridbox');
            gridbox.imgURL = "../../codebase/imgs/";
            gridbox.setSkin("XP");
            gridbox.enableAutoHeight(true);
            gridbox.enableAutoWidth(true);
            gridbox.init();
            gridbox.loadXML("sample.xml");

i would like to pass an json file instead of XML so how my JSON should be made corresponding to the provided sample.xml.

Answer posted by Support on Jun 24, 2008 02:49
a) current version of JSON doesn't support full grid configuration ( the head section in XML )

For other data it will look as

<rows>
<row id="Business/Services">
<cell image="folder.gif">Business/Services</cell>
<cell style="background-color:#336633;color:#336633;">1</cell>
<cell style="background-color:#336633;color:#336633;">1</cell>
<cell style="background-color:#336633;color:#336633;">1</cell>


{ rows: [
    {
        id:"Business/Services",
        data:["Business/Services","1","1","1"]
    }
]}