Skip to content

Latest commit

 

History

History
241 lines (179 loc) · 4.63 KB

Tree-Documentation.pod

File metadata and controls

241 lines (179 loc) · 4.63 KB

Class Tree Documentation

Description

Class Tree - XML Generator for DHTMLX

construct

$tree = new Tree( set encoding, default utf-8 )

$tree = new Tree;

or

$tree = new Tree('iso-8859-1');

attributes

id

$tree->id = 0; // default 0

radio

$tree->radio = 0;

order

$tree->order = "asc";

item

$tree->item( array( 'key attribute' => 'value attribute' ) )

$tree->item(
    array(
        "id" => "p1",
        "text" => "parent item 1",
        "select" => "1",
        "call" => "1"
        "userdata" => array(
            "name" => "some1",
            "value" => "Value 1"
        ),
        "item" => array(
            array(
                 "id" => "c1-0", 
                 "text" => "child item 1"
            ),
            array(
                 "id" => "c1-1", 
                 "text" => "child item 2"
            )
        )
    )
);

start and end

$tree->start( array( 'key attribute' => 'value attribute' ) ) and $form->end()

$tree->start(
    array(
        "id" => "p1",
        "text" => "parent item 1",
        "select" => "1",
        "call" => "1"
    )
);

$tree->item(
    array(
         "id" => "c1-0", 
         "text" => "child item 1"
    ),
    array(
         "id" => "c1-1", 
         "text" => "child item 2"
    )
);

$tree->end();
        

itemtext

$tree->itemtext( ' value ' )

$tree->itemtext("Value");

userdata

$tree->userdata( array( 'key attribute' => 'value attribute' ) )

$tree->userdata(
    array(
        "name" => "some1",
        "value" => "Value1"
    ),
    array(
        "name" => "some2",
        "value" => "Value2"
    )
);

header

$tree->header()

$tree->header();

return

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

result

$tree->result()

echo $tree->result();

Print XML

Examples

Example 1

Mode 1

<?php
include_once 'DHX.php';

$tree = new Tree;

$tree->item(
    array(
        "id" => "p1",
        "text" => "parent item 1",
        "select" => "1",
        "call" => "1",
        "itemtext" => "Value Item Text",
        "userdata" => array(
            "name" => "some1",
            "value" => "Value 1"
        ),
        "item" => array(
            array(
                 "id" => "c1-0", 
                 "text" => "child item 1"
            ),
            array(
                 "id" => "c1-1", 
                 "text" => "child item 2"
            )
        )
    )
);

$tree->header();
echo $tree->result();
?>

Result

<?xml version="1.0" encoding="utf-8"?>
<tree id="0">
    <item id="p1" text="parent item 1" select="1" call="1">
        <itemtext>
            <![CDATA[ Value Item Text ]]>
        </itemtext>
        <userdata name="some1">Value 1</userdata>
        <item id="c1-0" text="child item 1"/>
        <item id="c1-1" text="child item 2"/>
    </item>
</tree>

Mode 2

<?php
include_once 'DHX.php';

$tree = new Tree("iso-8859-1");

// start p1
$tree->start(
    array(
        "id" => "p1",
        "text" => "parent item 1",
        "select" => "1",
        "call" => "1",
    )
);

$tree->itemtext("Value Item Text");

$tree->userdata(
    array(
        "name" => "some1",
        "value" => "Value 1"
    )
);

$tree->item(
    array(
         "id" => "c1-0", 
         "text" => "child item 1"
    ),
    array(
         "id" => "c1-1", 
         "text" => "child item 2"
    )
);

$tree->end(); // end p1

$tree->header();
echo $tree->result();
?>

Result

<?xml version="1.0" encoding="iso-8859-1"?>
<tree id="0">
    <item id="p1" text="parent item 1" select="1" call="1">
        <itemtext>
            <![CDATA[ Value Item Text ]]>
        </itemtext>
        <userdata name="some1">Value 1</userdata>
        <item id="c1-0" text="child item 1"/>
        <item id="c1-1" text="child item 2"/>
    </item>
</tree>

Author

Lucas Tiago de Moraes

Support

Group DHTMLX Facebook