Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted on Feb 27, 2007 19:36
open dhtmlx forum
In your features documentation you mention that dhtmlxTreeGrid has the ability to load data dynamically, but ...

In your features documentation you mention that dhtmlxTreeGrid has the ability to load data dynamically, but it seems that it can only be loaded by scrolling (a great feature).  However, I was wondering if it also had the ability to load the tree nodes as they are expanded (via AJAX).
Answer posted on Feb 27, 2007 19:39

Sure, the grid can load child rows while expanding parent row.

You can check samples/pro_treeGrid_dynamic.html (the  sample available only in PRO package).

 

<div id="gridbox" width="100%" height="250px" style="background-color:white;overflow:hidden"></div>
<script>
                        mygrid = new dhtmlXGridObject('gridbox');
                        ...
                        mygrid.kidsXmlFile="pro_treeGrid_dynamic.php";
                        mygrid.loadXML("pro_treeGrid_dynamic.php");       

    ==================  pro_treeGrid_dynamic.php ========================

    <?php

    //the php file must be recognized as XML document so necessary header sent

    header("Content-type:text/xml");

    //default xml file header (UTF-8 is a common value, but in some cases another encoding must be used)

    print('<?xml version="1.0" encoding="UTF-8"?>');

    //the script receive a parent item id from GET scope as my_script.php?id=PARENT_ID
    //if parent id not sent - top level in related sample - then  set it equal to 0

    if (!isset($_GET['id']))  $_GET['id']=0;

    //write top tag of xml document, the parent attribute contain id of parent row

    print ("<rows parent='".$_GET['id']."'>");

    //in real code here you must take records from DB
  //in sample we simple create a 20 dummy records

    for($i = 0;$i<20;$i++){

        //row tag contain a id and xmlkids attributes
        //if xmlkids attribute exists and is not empty - the row will be drawn as expandable
        //in our sample each 4th row will be expandable

        print "<row id='a_{$_GET['id']}_{$i}' xmlkids='".(($i%4==0)?1:"")."'>";

        //value of row

        print ("<cell image='folder.gif'>Item {$_GET['id']}:{$i}</cell>");

        //close row tag

        print ("</row>");
    }
    //after drawing all childs of current row, the main tag must be closed

    print("</rows>");

</script>

Answer posted by sematik (Support) on Dec 07, 2014 00:09

If you haven't found the needed information there and still looking for a solution, you will find the additional help checking ajax file upload with progress bar and javascript calendar date.