Diagram PHP Class Overview

The Kendo UI Diagram for PHP is a server-side wrapper for the Kendo UI Diagram widget.

Getting Started

You can populate a Kendo UI Diagram for PHP with remote binding. The Diagram makes AJAX requests and is bound to JSON result.


Below are listed the steps for you to follow when configuring the Kendo UI Diagram for PHP with Ajax binding.

Step 1 Make sure you followed all the steps from the introductory article on Telerik UI for PHP—include the autoloader, JavaScript, and CSS files.

Step 2 Create a Diagram and configure it.

    // Specify the url of the PHP page which will act as the remote service
    $read = new \Kendo\Data\DataSourceTransportRead();

    $transport = new \Kendo\Data\DataSourceTransport();

    // Configure the model
    $model = new \Kendo\Data\HierarchicalDataSourceSchemaModel();

    $schema = new \Kendo\Data\HierarchicalDataSourceSchema();

    // Configure data source
    $dataSource = new \Kendo\Data\HierarchicalDataSource();

Step 3 Create a Diagram and set its data source.

    $layout = new \Kendo\Dataviz\UI\DiagramLayout();

    $diagram = new \Kendo\Dataviz\UI\Diagram('diagram');

Step 4 Output the Diagram by echoing the result of the render method.

    echo $diagram->render();

Event Handling

You can subscribe to all Diagram events.

Specify Function Names

The example below demonstrates how to subscribe for events by specifying a JavaScript function name.

    $diagram = new \Kendo\Dataviz\UI\Diagram('diagram');

    // The 'diagram_dataBound' JavaScript function will handle the 'dataBound' event of the diagram

    echo $diagram->render();
    function diagram_dataBound() {
        // Handle the dataBound event

Provide Inline Code

The example below demonstrates how to subscribe to events by providing inline JavaScript code.

    $diagram = new \Kendo\Dataviz\UI\Diagram('diagram');

    // Provide inline JavaScript code that will handle the 'dataBound' event of the diagram
    $diagram->dataBound('function() { /* Handle the dataBound event */ }');

    echo $diagram->render();


Client-Side Instances

You are able to reference an existing Diagram instance via the jQuery.data(). Once a reference is established, use the Diagram API to control its behavior.

    // Put this after your Kendo Diagram for PHP
        $(function() {
            // Notice that the name of the diagram is used to get its client-side instance
            var diagram = $("#diagram").data("kendoDiagram");

See Also

In this article