Kendo UI Extension for Yii 2
Currently implemented DataSource which is generating on ActiveRecord model-base., (*1)
Can be used with:
* Kendo Grid
* Kendo List
* other features that require DataSources, (*2)
Installation
The preferred way to install this extension is through composer., (*3)
Either run, (*4)
php composer.phar require --prefer-dist tigrov/yii2-kendoui
, (*5)
or add, (*6)
"tigrov/yii2-kendoui": "~1.0"
, (*7)
to the require section of your composer.json
file., (*8)
Also since there is yii2-kendoui 2.0 in development now,
make sure you have a version constraint in your composer.json
,
that does not allow it to be installed automatically on update,
so when next major version of yii2-kendoui is released,
your project won't break by itself.
A version constraint that does not include 2.0 is for example ~1.0,
make sure you do not have >= or * in version constraints in composer.json
., (*9)
To try the new version of yii2-kendoui add, (*10)
"tigrov/yii2-kendoui": "2.x-dev"
, (*11)
to the require section of your composer.json
file., (*12)
See more at Tigrov/yii2-kendoui/tree/2, (*13)
How to use?
@app/controllers/AddressController.php, (*14)
use \tigrov\kendoui\KendoBuild;
class AddressController extends Controller
{
public function actionIndex()
{
return $this->render('index');
}
public static function kendoActions()
{
// Address extends of ActiveRecord
$options = [
'model' => Address::className(),
'query' => [
'where' => ['status_id' => Address::STATUS_ACTIVE],
],
];
return KendoBuild::actions($options);
}
public function actions()
{
return array_merge(parent::actions(), static::kendoActions());
}
}
@app/views/address/index.php, (*15)
setTitle(\Yii::t('user', 'Addresses'));
KendoAsset::register($this);
$dataSource = \Yii::createObject([
'class' => DataSource::className(),
]);
$dataSourceSettings = $dataSource->getSettings();
$dataSourceJson = json_encode($dataSourceSettings);
$this->registerJs(
= \Yii::t('pro', 'Add new Address'); ?>, (*16)