Skip to content

Latest commit

 

History

History
379 lines (299 loc) · 8.17 KB

Grid-Documentation.pod

File metadata and controls

379 lines (299 loc) · 8.17 KB

Class Grid Documentation

Description

Class Grid - XML Generator for DHTMLX

construct

$grid = new Grid( set encoding, default utf-8 )

$grid = new Grid;

or

$grid = new Grid('iso-8859-1');

attributes

pos

$grid->pos = 100;

total_count

$grid->total_count = 1000;

settings

$grid->settings( array( 'key attribute' => 'value attribute' ) )

$grid->settings(
    array(
        "colwidth" => "px",
        "splitat" => 2
    )
);

column

$grid->column( array( 'key attribute' => 'value attribute' ) )

column simple

$grid->column(
    array(
         "type" => "edn",
         "width" => "150",
         "sort" => "str",
         "format" => "0.00",
         "label" => "Foo"
    ),
    array(
         "type" => "edn",
         "width" => "150",
         "sort" => "str",
         "format" => "0.00",
         "label" => "Bar"
    ),
    array(
         "type" => "edn",
         "width" => "150",
         "sort" => "str",
         "format" => "0.00",
         "label" => "Baz"
    )
);

column with combo option

$grid->column(
    array(
        "type" => "co",
        "width" => "150",
        "sort" => "na",
        "id" => "last",
        "label" => "Combo",
        "option" => array(
            array("value" => "1", "text" => "One"),
            array("value" => "2", "text" => "Two"),
            array("value" => "3", "text" => "Three")
        )
    )
);

beforeInit

$grid->beforeInit('command', 'value 1', 'value 2', ...)

$grid->beforeInit("enableResizing", "false", "false");

afterInit

$grid->afterInit('command', 'value 1', 'value 2', ...)

$grid->afterInit("enableResizing", "Label 2-1", "Label 2-2");  

row

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

$grid->row(
    array(
        "id" => 1,
        "cell" => array("foo", "bar", "baz")
    ),
    array(
        "id" => 2,
        "cell" => array("foo", "bar", array("class" => "css2", "text" => "baz"))
    ),
    array(
        "id" => 3,
        "userdata" => array("name" => "some1", "value" => "Value 1"),
        "cell" => array("foo", "bar", "baz")
    ),
    array(
        "id" => 4,
        "userdata" => array("name" => "some2", "value" => "Value 2"),
        "cell" => array("foo", "bar", "baz")
    )
);

cell

$grid->cell('id', 'value 1', 'value 2', ...)

$grid->cell(1, "foo", "bar", "baz");
$grid->cell(2, "foo", "bar", "baz");
$grid->cell(3, "foo", "bar", "baz");
$grid->cell(4, "foo", "bar", "baz");

userdata

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

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

header

$grid->header()

$grid->header();

return

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

result

$grid->result()

echo $grid->result();

Print XML

Examples

Example 1

Mode 1

<?php
include_once 'DHX.php';

$grid1 = new Grid;

$grid1->row(
    array(
        "id" => 1,
        "cell" => array("foo 1", "bar 1", "baz 1")
    ),
    array(
        "id" => 2,
        "cell" => array("foo 2", "bar 2", "baz 2")
    ),
    array(
        "id" => 3,
        "cell" => array("foo 3", "bar 3", "baz 3")
    ),
    array(
        "id" => 4,
        "cell" => array("foo 4", "bar 4", "baz 4")
    ),
    array(
        "id" => 5,
        "cell" => array("foo 5", "bar 5", "baz 5")
    )
);

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

Result

<?xml version="1.0" encoding="utf-8"?>
<rows>
    <row id="1">
        <cell>foo 1</cell>
        <cell>bar 1</cell>
        <cell>baz 1</cell>
    </row>
    <row id="2">
        <cell>foo 2</cell>
        <cell>bar 2</cell>
        <cell>baz 2</cell>
    </row>
    <row id="3">
        <cell>foo 3</cell>
        <cell>bar 3</cell>
        <cell>baz 3</cell>
    </row>
    <row id="4">
        <cell>foo 4</cell>
        <cell>bar 4</cell>
        <cell>baz 4</cell>
    </row>
    <row id="5">
        <cell>foo 5</cell>
        <cell>bar 5</cell>
        <cell>baz 5</cell>
    </row>
</rows>

Mode 2

<?php
include_once 'DHX.php';

$grid2 = new Grid("iso-8859-1");

$grid2->cell(1, "foo 1", "bar 1", "baz 1");
$grid2->cell(2, "foo 2", "bar 2", "baz 2");
$grid2->cell(3, "foo 3", "bar 3", "baz 3");
$grid2->cell(4, "foo 4", "bar 4", "baz 4");
$grid2->cell(5, "foo 5", "bar 5", "baz 5");

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

Result

<?xml version="1.0" encoding="iso-8859-1"?>
<rows>
    <row id="1">
        <cell>foo 1</cell>
        <cell>bar 1</cell>
        <cell>baz 1</cell>
    </row>
    <row id="2">
        <cell>foo 2</cell>
        <cell>bar 2</cell>
        <cell>baz 2</cell>
    </row>
    <row id="3">
        <cell>foo 3</cell>
        <cell>bar 3</cell>
        <cell>baz 3</cell>
    </row>
    <row id="4">
        <cell>foo 4</cell>
        <cell>bar 4</cell>
        <cell>baz 4</cell>
    </row>
    <row id="5">
        <cell>foo 5</cell>
        <cell>bar 5</cell>
        <cell>baz 5</cell>
    </row>
</rows>

Example 2

<?php
include_once 'DHX.php';

$grid = new Grid;

// settings
$grid->settings(array("colwidth" => "px", "splitat" => 2));

// beforeInit
$grid->beforeInit("enableResizing", "false", "false");

// afterInit
$grid->afterInit("enableResizing", "Label 2-1", "Label 2-2");

// column
$grid->column(
    array(
        "type" => "ed",
        "width" => "150",
        "sort" => "str",
        "label" => "Name"
    ),
    array(
        "type" => "ed",
        "width" => "150",
        "sort" => "str",
        "label" => "E-mail"
    ),
    array(
        "type" => "ed",
        "width" => "150",
        "sort" => "str",
        "label" => "Login"
    )
);

// cell
$grid->cell(1, "Foo", "[email protected]", "foo");
$grid->cell(1, "Bar", "[email protected]", "bar");
$grid->cell(1, "Baz", "[email protected]", "baz");

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

Result

<?xml version="1.0" encoding="utf-8"?>
<rows>
    <head>
        <settings>
            <colwidth>px</colwidth>
            <splitat>2</splitat>
        </settings>
        <beforeInit>
            <call command="enableResizing">
                <param>false,false</param>
            </call>
        </beforeInit>
        <afterInit>
            <call command="enableResizing">
                <param>Label 2-1,Label 2-2</param>
            </call>
        </afterInit>
        <column type="ed" width="150" sort="str">Name</column>
        <column type="ed" width="150" sort="str">E-mail</column>
        <column type="ed" width="150" sort="str">Login</column>
    </head>
    <row id="1">
        <cell>Foo</cell>
        <cell>[email protected]</cell>
        <cell>foo</cell>
    </row>
    <row id="1">
        <cell>Bar</cell>
        <cell>[email protected]</cell>
        <cell>bar</cell>
    </row>
    <row id="1">
        <cell>Baz</cell>
        <cell>[email protected]</cell>
        <cell>baz</cell>
    </row>
</rows>

Author

Lucas Tiago de Moraes

Support

Group DHTMLX Facebook