Код: Выделить всё
<?php $this->beginContent('@app/views/layouts/main.php'); ?>
<div class="container">
<div class="row">
<div class="col-lg-3 col-md-3 col-sm-3">
<?= kartik\tree\TreeViewInput::widget([
// single query fetch to render the tree
// use the Product model you have in the previous step
'query' => frontend\models\Tree::find()->addOrderBy('root, lft'),
'headingOptions'=>['label'=>'Categories'],
'name' => 'kv-product', // input name
'value' => '1', // values selected (comma separated for multiple select)
'asDropdown' => true, // will render the tree input widget as a dropdown.
'multiple' => false, // set to false if you do not need multiple selection
//'fontAwesome' => true, // render font awesome icons
'rootOptions' => [
'label'=>'<i class="fa fa-tree"></i>', // custom root label
'class'=>'text-success'
],
'options'=>['disabled' => false],
'displayValue' => 0,
'isAdmin' => true,
'showIDAttribute' => true,
'emptyNodeMsg' => ' type some msg here ... .',
'showCheckbox' => true,
'options' => ['id' => 'treeID'],
'allowNewRoots' => false,
'toolbar' => [
'create' => ['alwaysDisabled' => true],
//'remove' => ['alwaysDisabled' => !(AdminController::isAdmin())],
// 'move-up' => ['alwaysDisabled' => !(AdminController::isAdmin())],
// 'move-down' => ['alwaysDisabled' => !(AdminController::isAdmin())],
// 'move-left' => ['alwaysDisabled' => !(AdminController::isAdmin())],
// 'move-right' => ['alwaysDisabled' => !(AdminController::isAdmin())],
//'remove' => false,
],
'nodeView' => '@kvtree/views/_form',
'cascadeSelectChildren' => false,
//'nodeAddlViews' => [,
//],
]);?>
</div>
<div class="col-lg-9 col-md-9 col-sm-8">
<?= $content ?>
</div>
</div>
</div>
<?php $this->endContent(); ?>
<script>
$('#treeID').on('treeview:selected', function(event, key, data, textStatus, jqXHR)
{
console.log('treeview:selected')
});
</script>