PHPackages                             kasoft/yii2-jstree - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kasoft/yii2-jstree

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

kasoft/yii2-jstree
==================

jsTree is jquery plugin, that provides interactive trees

v1.0.16(1y ago)456.4k—7.7%3MITPHPPHP &gt;=7.2

Since Dec 6Pushed 8mo agoCompare

[ Source](https://github.com/kasoft/yii2-jstree)[ Packagist](https://packagist.org/packages/kasoft/yii2-jstree)[ RSS](/packages/kasoft-yii2-jstree/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (18)Used By (0)

Extension für jsTree Plugin
===========================

[](#extension-für-jstree-plugin)

jsTree for Yii2 is a Extension to display an handle ActiveRecord Models with jsTree.

- load tree data with ajax and display tree
- define icons for different tree items (e.g. with FontAwesome)
- context menu with update, rename and delete
- move tree items by drag'n'drop
- context submenu with individual node types
- dynamic context menu where items for special types can be removed
- individual text and context menu messages

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist kasoft/yii2-jstree "1.0.14"

```

or add

```
"kasoft/yii2-jstree": "1.0.14",

```

to the require section of your `composer.json` file.

Latest News
-----------

[](#latest-news)

Version 1.0.16

- Removed unnecessary Bootstrap Dependency

Version 1.0.14

- Define a id wich node via initialOpenId wich will open after load

Version 1.0.13

- Individuall "New node" Text can be set in standardMsg

Version 1.0.12

- Fixed missing Icon for Duplicate

Version 1.0.11

- New: Duplicate Items in Kontext Menu with Model Duplication
- Yii2 Error Messages while create or duplicate are transportet to Javascript Alert
- Remove Contextmenu Items for special Types (e.g. No "delete" for type "page")

Version 1.0.10

- Fixed array\_merge error

Version 1.0.9

- More Text that could be translated
- Fixed rename error

Version 1.0.8

- Set individual Context Menu Text and individual Alert Messages
- Choose which Context Menu should be displayed (create, edit, delete, rename)
- Set individual Icon for each Enty
- Setup a create Submenu with different new node Types and define these Node Type as described in JsTree Docs with different possibilities (allow childs, allow move, set icon)

Version 1.0.7

- Added modelPropertyType with default value + online/offline glyphicons as default

Version 1.0.6

- Fixed a Problem with Yii 2.0.14, because of a diffrent Error Handling, the Tree wasn't displayes
- REQUEST check in Controller isn't needed any more

Version 1.0.5

- Selecting a Node will trigger update action via Ajax and load result in .jstree-result div. If the .jstree-result is not found, it will redirect to Update Action
- Changed all Submenu Icons to Glyhicon

Version 1.0.4

- Updated Composer Settings

Version 1.0.3

- Selected multiple Nodes are all deleted

Usage without Model (JSON only)
-------------------------------

[](#usage-without-model-json-only)

The simple Version just displays the tree with a provided json url. You have to provide the json data by an url

```
$tree = new \kasoft\jstree\JsTree([
    'jsonUrl' => '/my_jsonurl/data/whatever',
]);
```

```

```

Usage with Yii2 Model
---------------------

[](#usage-with-yii2-model)

If you want to use the Extension so Display the Tree from your Data, do Operations like move, create, delete, rename and open the form view by Click use this Version.

Before you start, check your Database or your Model! Do you have all required Fields?

Together with a Database (tested with MySQL) and a set of Fields to order and structure the tree are needed. The Tree is displayed in a DIV. The Extensions handels create, move, rename and delete for you. A click on a Tree Item will dipslay the form to edith data in another div.

See the Test Setup in the "demo" Folder!

Set up you Database with the needed fileds (can have different names) \*name Name or Titel to Display in in the tree (required) \*parent\_id Id for nesting the tree (required) \*position For sorting the tree items (required) \*type Type of the Item, used for Icon and rights (optional)

Set up your Model with these Fields. Important: Only the name is allwoed to be a required Field! Otherwise the Contextmenue "New" will probably not work.

Add this to your Controller. All Items with (\*) are required!

```
