1. Go to this page and download the library: Download kasoft/yii2-jstree library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kasoft / yii2-jstree example snippets
$tree = new \kasoft\jstree\JsTree([
'jsonUrl' => '/my_jsonurl/data/whatever',
]);
<?
public function actionIndex() {
$tree = new \kasoft\jstree\JsTree([
'modelName'=>'backend\models\MY_MODEL_NAME', // * Namespace of the Model
'modelPropertyId' => 'id' // * primary Key
'modelPropertyParentId' => 'parentId', // * Parent ID for tree items
'modelPropertyPosition' => 'position', // *for sorting items
'modelPropertyName' => 'name', // * Fieldname to show
'modelFirstParentId' => NULL, // * ID for the Tree to start
'modelPropertyType' => 'type', // Item type (for Icon and jsTree rights)
'controllerId' => 'index', // Controler Actions which should handle everything
'jstreeDiv' => '#jstree', // DIV where the Tree will be displayed
'jstreeIcons' => false, // Show Icons or not
'jstreePlugins' => ["contextmenu", "dnd",..], // Plugins to be load
'jstreeContextMenue' => [ // Define individual menu
"remove" => [
"text" => "Delete",
"icon" => "glyphicon glyphicon-plane",
],
"edit" => [
"text" => "Edit",
"icon" => "glyphicon glyphicon-picture",
],
"create" => [
"text" => "Create new",
"icon" => "glyphicon glyphicon-barcode",
"type"=> "online",
"submenu" => [ //Define submenu for creating node types
["text"=>"Create new with Type offline","icon" => "glyphicon glyphicon-barcode","type"=>"offline"],
["text"=>"Create new with Type online","icon" => "glyphicon glyphicon-plane", "type"=>"online"],
["text"=>"Create new with Type default","glyphicon glyphicon-volume-up","type"=>""],
]
],
"rename" => [
"text" => "Rename",
"icon" => "glyphicon glyphicon-volume-up",
],
],
'jstreeType' => [ // jsTree Type Options
"#" => [
"max_children" => -1,
"max_depth" => -1,
"valid_children" => -1,
"icon" => "glyphicon glyphicon-th-list"
],
"default" => [
"icon" => "glyphicon glyphicon-question-sign"
],
],
'jstreeMsg' => [ // Individual Alert Messages
"confirmdelete" => "Are you sure? Delete?",
"nothere" => "Not possible at this Position!",
]
]);
return $this->render('index');
}
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.