PHP Classes
elePHPant
Icontem

Kendo UI PHP Framework: Build user interface with Telerik Kendo UI library

Recommend this page to a friend!
  Info   View files Documentation   View files View files (20)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2016-08-02 (2 months ago) RSS 2.0 feedNot enough user ratingsTotal: 64 All time: 8,568 This week: 1,081Up
Version License PHP version Categories
kendo 1.0.0MIT/X Consortium ...5.4HTML, PHP 5
Description Author

This package can build a user interface with Telerik Kendo UI library.

It can generate HTML with JavaScript to compose Web based user interfaces using components of the Kendo UI JavaScript library.

The package main class can create objects that are wrappers around the Kendo UI widgets, set properties and set data sources objects.

Picture of Tomas Saghy
  Performance   Level  
Name: Tomas Saghy <contact>
Classes: 2 packages by
Country: Slovak Republic Slovak Republic

Details

PHP wrapper for Kendo UI widgets

Build Status Latest Version Total Downloads Software License

Kendo UI is a great JavaScript library. It offers both open-source and commercial editions.

This library provides a wrapper for all Kendo UI widgets. Telerik provides PHP wrappers itself, but these are unnecessarily complex and in addition they are payed. Our library is released under the MIT license, so you are free to use it in any project (even commercial projects) as long as the copyright header is left intact.

Installation

Install the latest version using composer require riesenia/kendo

Or add to your composer.json file as a requirement:

{
    "require": {
        "riesenia/kendo": "~1.0"
    }
}

Usage

Any widget can be created calling the create method of Kendo class. For example creating a grid with selector "#grid" (resulting in $("#grid").kendoGrid({ ... }) can be achieved by calling:

use Riesenia\Kendo\Kendo; 

echo Kendo::create('Grid')->bindTo('#grid');

or faster by:

use Riesenia\Kendo\Kendo; 

echo Kendo::createGrid('#grid');

Setting properties

Any property can be set by calling set method. For adding to properties that are represented by array (or objects), add method can be used. Set method can be also used for batch assignment by passing array as the only parameter. To NOT encode passed data, pass them wrapped by Kendo::js() call. All the methods return the instance so calls can be chained. Examples:

use Riesenia\Kendo\Kendo; 

$grid = Kendo::createGrid('#grid');

// set any property
$grid->setHeight(100);

// set property, that should not be encoded
$grid->setChange(Kendo::js('function(e) {
    console.log(this.select());
}'));

// set properties by array
$grid->set([
    'height' => 100,
    'change' => Kendo::js('function(e) {
        console.log(this.select());
    }')
]);

// add to property
$grid->addColumns(null, 'Name')
    ->addColumns(null, ['field' => 'Surname', 'encoded' => false]);

// pass DataSource object
$grid->setDataSource(Kendo::createDataSource());

Complex example

Creating code for grid as in this example:

use Riesenia\Kendo\Kendo; 

$model = Kendo::createModel()
    ->addField('ProductName', ['type' => 'string'])
    ->addField('UnitPrice', ['type' => 'number'])
    ->addField('UnitsInStock', ['type' => 'number'])
    ->addField('Discontinued', ['type' => 'boolean']);

$dataSource = Kendo::createDataSource()
    ->setData(Kendo::js('products'))
    ->setSchema(['model' => $model])
    ->setPageSize(20);

echo Kendo::createGrid('#grid')
    ->setDataSource($dataSource)
    ->setHeight(550)
    ->setScrollable(true)
    ->setSortable(true)
    ->setFilterable(true)
    ->setPageable(['input' => true, 'numeric' => false])
    ->setColumns([
        'ProductName',
        ['field' => 'UnitPrice', 'title' => 'Unit Price', 'format' => '{0:c}', 'width' => '130px'],
        ['field' => 'UnitsInStock', 'title' => 'Units In Stock', 'width' => '130px'],
        ['field' => 'Discontinued', 'width' => '130px']
    ]);

Observable (MVVM)

Rendering for Kendo observable is slightly different. Predefined variable name is viewModel, but this can be overridden by the method variableName. Example:

use Riesenia\Kendo\Kendo; 

echo Kendo::createObservable('#view')
    ->variableName('myMvvm')
    ->setFirstName('John')
    ->setLastName('Doe')
    ->setDisplayGreeting(Kendo::js('function() {
        alert("Hello, " + this.get("firstName") + " " + this.get("lastName") + "!!!");
    }'));

This will output:

myMvvm = kendo.observable({
    "firstName": "John",
    "lastName": "Doe",
    "displayGreeting": function () {
        alert("Hello, " + this.get("firstName") + " " + this.get("lastName") + "!!!");
    }
});
kendo.bind($("#view"), myMvvm);

Tests

You can run the unit tests with the following command:

$ cd path/to/riesenia/kendo
$ composer install
$ vendor/bin/phpspec run
  Files folder image Files  
File Role Description
Files folder imagespec (2 files, 1 directory)
Files folder imagesrc (2 files, 1 directory)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpspec.yml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  spec  
File Role Description
Files folder imageWidget (5 files)
  Plain text file JavascriptFunctionSpec.php Class Class source
  Plain text file KendoSpec.php Class Class source

  Files folder image Files  /  spec  /  Widget  
File Role Description
  Plain text file BaseSpec.php Class Class source
  Plain text file DataSourceSpec.php Class Class source
  Plain text file HierarchicalDataSourceSpec.php Class Class source
  Plain text file ModelSpec.php Class Class source
  Plain text file ObservableSpec.php Class Class source

  Files folder image Files  /  src  
File Role Description
Files folder imageWidget (6 files)
  Plain text file JavascriptFunction.php Class Class source
  Plain text file Kendo.php Class Class source

  Files folder image Files  /  src  /  Widget  
File Role Description
  Plain text file Base.php Class Class source
  Plain text file DataSource.php Class Class source
  Plain text file HierarchicalDataSource.php Class Class source
  Plain text file Model.php Class Class source
  Plain text file Observable.php Class Class source
  Plain text file TreeListDataSource.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:64
This week:0
All time:8,568
This week:1,081Up