Class TreeGrid Documentation

Description

Class TreeGrid - XML Generator for DHTMLX

construct

$treegrid = new TreeGrid( set encoding, default utf-8 )

    $treegrid = new TreeGrid;

or

    $treegrid = new TreeGrid('iso-8859-1');

attributes

parent

    $treegrid->parent = 1; // default 0

row

$treegrid->row( array( 'key attribute' => 'value attribute' ) )

    $treegrid->row(
        array(
            "id" => 11,
            "open" => 1,
            "cell" => array("Value 1", "Value 2", "Value 3")
        )
    );

start and end

$treegrid->start( array( 'key attribute' => 'value attribute' ) ) and $menu->end()

    $treegrid->start(
        array(
            "id" => 11,
            "open" => 1
        )
    );
    
    $treegrid->cell("Value 1", "Value 2");
    
    $treegrid->end();

cell

$treegrid->cell( array( 'key attribute' => 'value attribute' ) or 'value' )

    $treegrid->start(
        array(
            "id" => 11,
            "open" => 1
        )
    );
    
    $treegrid->cell("Value 1", "Value 2", array("image" => "some.gif", "text" => "Value 3"));
    
    $treegrid->cell(array("image" => "value.gif", "text" => "Value 4");
    
    $treegrid->end();

header

$treegrid->header()

    $treegrid->header();

return

    header("Content-type: application/xml; charset=utf-8");

result

$treegrid->result()

    echo $treegrid->result();

Print XML

Examples

Example 1

Mode 1

    <?php
    include_once 'DHX.php';
    
    $treegrid = new TreeGrid;
    
    $treegrid->row(
        array(
            "id" => 11,
            "open" => 1,
            "cell" => array(
                "Value 1",
                "Value 2",
                array(
                    "image" => "some.gif",
                    "text" => "Value3"
                )
            ),
            "row" => array(
                array(
                    "id" => 110,
                    "cell" => array(
                        "first column data",
                        "second column data"
                    )
                )
            )
        )
    );
    
    $treegrid->header();
    echo $treegrid->result();
    ?>

Result

    <?xml version="1.0" encoding="utf-8"?>
    <rows parent="0">
        <row id="11" open="1">
            <cell>Value 1</cell>
            <cell>Value 2</cell>
            <cell image="some.gif">Value3</cell>
            <row id="110">
                <cell>first column data</cell>
                <cell>second column data</cell>
            </row>
        </row>
    </rows>

Mode 2

    <?php
    include_once 'DHX.php';
    
    $treegrid = new TreeGrid("iso-8859-1");
    
    // start id 11
    $treegrid->start(
        array(
            "id" => 11,
            "open" => 1,
        )
    );
    
    $treegrid->cell("Value 1", "Value 2", array("image" => "some.gif", "text" => "Value3"));
    
    // start id 110
    $treegrid->start(
        array(
            "id" => 110
        )
    );
    
    $treegrid->cell("first column data", "second column data");
    
    $treegrid->end(); // end id 110
    
    $treegrid->end(); // end id 11
    
    $treegrid->header();
    echo $treegrid->result();
    ?>

Result

    <?xml version="1.0" encoding="iso-8859-1"?>
    <rows parent="0">
        <row id="11" open="1">
            <cell>Value 1</cell>
            <cell>Value 2</cell>
            <cell image="some.gif">Value3</cell>
            <row id="110">
                <cell>first column data</cell>
                <cell>second column data</cell>
            </row>
        </row>
    </rows>

Author

Lucas Tiago de Moraes

Support

Group DHTMLX Facebook