riesenia/kendo
Composer 安装命令:
composer require riesenia/kendo
包简介
PHP wrapper for Kendo UI widgets
README 文档
README
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 paid. 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": "~3.0"
}
}
Note: if you use PHP 5.4 - 5.6 use 1.* version of this library.
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 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 method 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);
riesenia/kendo 适用场景与选型建议
riesenia/kendo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 41.67k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2014 年 12 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 riesenia/kendo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 riesenia/kendo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 41.67k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 12
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-12-23