It is a adapter for Yii2 that transforms Kendo Grid`s frontend requests into ActiveQuery on backend. Supports all KendoGrid`s filtering, sorting, searching etc.
- Add following line into
require
section in yourcomposer.json
:
"require": {
"megapixel23/kendo-yii2-adapter": "dev-master"
}
- If you want to install package directly from GitHub, you need to add following line into
repositories
section in yourcomposer.json
to set up composer`s package source path:
"repositories": [
{
"type": "git",
"url": "https://github.com/MEGApixel23/kendo-yii2-adapter"
}
]
Frontend
var grid = $("#grid").kendoGrid({
dataSource: {
type: 'json',
transport: {
read: '/custom/action/handler'
},
schema: {
data: 'data',
total: 'total'
},
pageSize: 20,
serverPaging: true,
serverFiltering: true
},
filterable: {
mode: 'row'
},
pageable: true
}).data('kendoGrid');
Backend
public function actionCustomActionHandler()
{
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$query = Items::find();
$provider = new KendoDataProvider([
'query' => $query
]);
return [
'data' => $provider->getModels(),
'total' => $query->count()
];
}
}