Extension Nestedtree

new extension publication in progress…

http://www.yiiframework.com/extension/nestedtree/

Waiting for your bug reports or any question concentrated nested set in tree.

looks good …

Thanks!

Just The last check of codes, and version 1.0 is going to be published, hopefully today, or tomorrow.

> Thank you for your patient! Extension is tested, and you can download it !

I will give it a try …

Thank you

actually i 'v used these two extension a long time(before the yii danyTree extension came out) look at this jdynaTree . :lol:

they can go together well. and i also use my jcontextMenu . so it is absolutely possible three extension go together !

drag and drop to do the ordering . with context menu you can add child ,delete child ,refresh a node …

Thanks for your good impression!

I found a good sample in dynaTree example browser to use context menu together with them.

In the center of developing my own extension was using dynaTree with nested set model together in the easiest way.

I collect every other impression for next improvement of this extension, and the context menu inplementation will be the first!

I was having some trouble getting the ControllerMap to find the built in controller/action and I found this to help - especially in localhost environment where the app usually resides in a sub folder. Maybe this could be built into the extension?





<?php

$this->widget('ext.NestedDynaTree.NestedDynaTree', array(

    ...

    'ajaxController' => Yii::app()->baseUrl . '/AXtree/'

));

?>



Matt

Thanks for your report and the good suggestion of the solution!

I used online test enviroment only, and didn`t test this extension on localhost enviroment.

I collect some more impressions, issues and improvement suggestion to publicate next relase of nestedtree extension, but your suggestion will be mentioned in the extension documentation.

Hi,

after playing a bit:

1/ error on creating a new "page":


CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'name_UNIQUE'. The SQL statement executed was: INSERT INTO `page` (`root`, `lft`, `rgt`, `level`) VALUES (:yp0, :yp1, :yp2, :yp3)

request was: AXtree/insert with

POST parameters: model:Page, source:1,mode:after,YII_CSRF_TOKEN:e18e6f2f74194bb26c8f5f55d3a228352cb25a2b

However, an empty page is created …

2/ can get the multi roots feature of NestedSetBehavior to work … (I think that AxController load action is repsonsible of that, didn’t have the time to investigate it further)

3/ drag’n’drop work like a charm: good work

My suggestion:

use context menu for node creation and deletion. And keep on the good work :D

Thank you

Hi Luc,

Thank you for your time, and help!

First error is came form the unique name value of the model.


CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'name_UNIQUE'. The SQL statement executed was: INSERT INTO `page` (`root`, `lft`, `rgt`, `level`) VALUES (:yp0, :yp1, :yp2, :yp3)

This is handled normally in the model, like here:


    

public function beforeSave() {

        if ($this->isNewrecord) {


            $this->name = $this->getNextMaxValue('name', "new_");

         }

        $this->datum_create = new CDbExpression('NOW()');

        return parent::beforeSave();

    }



The getNextMaxValue() function is implemented both NestedTreeActiveRecord and NestedTreeBehavior.

It sould be better - in the next version - put the neme getNextMaxValue function into the AXController.




    public function actionInsert() {


        if (($modelClass = $this->getModel()) !== false) {

            $target = $modelClass::model()->findByPk($_POST['source']);

            $node = new $modelClass;

            $node->{$node->titleAttribute}=$node->getNextMaxValue($node->titleAttribute, "new_");

....

         



2. hasManyRoots

Thank to NestedSetBehavior it works, but:

[list=1]

[*] you should mannualy insert root in db

[*] you cannot delete any root from tree yet.

[/list]

next version will handle this issues.

3. Drag and drop

Thanks! It was the main aim of the game!

Suggesion: Context menu

It is in the list for next version… ( include new root function :) )

Next version

The next version will be relased in the next year.

If it is not so big problem, I’ll ask you that time to playing a bit with the new version!

Thanks at all!

András

thank you for your efforts.

Merry CHristmas.

Hi,

first of all it’s a pretty nice starting and i wish you good luck!

i’ve just playing with this extension and my question is how to set the name of node?

when i add a new one it’s become with an empty title.

thanx!

Hi Algebris,

Thanks for your words.

The new version is on the road, and there will be a prompt to get name of the node before adding it.

The title of the node is normally a Model responsibility.

There is a function in NestedTreeActiveRecord - getNextMaxValue() - to increment a title name if the title field in the model is unique.

In the AXController actionInsert() method you can define the value of the title field of the node too.

I hope I could help!

András

Hi,

how to edit the name of each new record?

In this version you can edit name and any other fields via normal CRUD form.

Set the clickAjaxLoadContainer property to your existing HTML element


<div id='content'></div>

and set clickAction property to your update Action in the CRUD controller (/Cathegories/update/).

See Usage:


/

<?php

        $this->widget('ext.NestedDynaTree.NestedDynaTree', array(

            //the class name of the model.

            'modelClass' => "Cathegories",

            // action taken on click on item. (default empty)

            'clickAction' => "/Cathegories/update/",

            //if given, AJAX load a result of clickAction to the container (default empty)

            'clickAjaxLoadContainer' => 'content',

            //can insert, delete and ( if enabled)drag&drop (default true) 

            'manipulationEnabled' => !Yii::app()->user->isGuest,

            //can sort items by drag&drop (default true)

            'dndEnabled' => true,

 

            //AJAX controller absolute path if you don`t use controllerMap

            // 'ajaxController'=>'/path/to/controller/' //default('/AXtree/')

        ));

        ?>



New version is going to release in February, 2013

I integrated one-click-editor to the extension.

Hi,

is it possible with your widget bot only to sort nodes but to rearrage them?

I mean, can I drop a node into anotther simple one to turn it into his child?

Thanks!

Hi,

Yes the widget has drag and drop capability, and you can rearrange items, drop to item to another as it’s child,

according to the normal behavior of Nested set.

The Next version has been delayed by the jquery.contextmenu plugin strange behavior.

Today I found a solution of the context menu problem. It was big deal, and I fount a very good documentation for context menu.

I share, it could be useful:

http://www.timgittos.com/archives/jquery-context-menu-unbind-click-fix/

I’m collecting more bugs, and ideas of improvement nesetedTree extension, and the next version will be published soon.

Hi,thanks for the great extension.i have followed the instruction,when i try to show it on the page,it gives me load error.i used your controller and your extended activerecord too.thanks