i am using jstree,Cjstree,and nestedset. I have apply every thing with full concentration but my view result is not displaying the right data.
Result:
[{"text":"Root<\/a>","id":"1"},{"text":"children<\/a>","id":"2"},{"text":"children2<\/a>","id":"3"}]
My Controller.php
<?php
class TreeController extends CController
{
public $layout='application.views.layouts';
protected function formatData($tree)
{
if($tree->getChildNodes())
return array('text'=>CHtml::link($tree->name,"#"),'id'=>$tree->id,'expanded'=>true);
else
return array('text'=>CHtml::link($tree->name,"#"),'id'=>$tree->id);
//return array($tree->name,$tree->id);
}
public function actionTree2()
{
$data=array();
$treeList1=tree::model()->findAll();
foreach ($treeList1 as $i=>$model) {
//echo "<br/>a".$model;
$data[$i]=$this->formatData($model);
$treeList2=$model->getChildNodes();
foreach ($treeList2 as $j=>$submodel) {
$data[$i]['children'][]=$this->formatData($submodel);
};
};
$this->render('tree2',array('data'=>$data));
}
}
?>
My view.php
<?php
$this->Widget(‘application.extensions.jsTree.CjsTree’, array(
'data'=>$data,
'ui'=>array('theme_name'=>'apple'),
'rules'=>array(
droppable => "tree-drop",
multiple => true,
deletable => "all",
draggable => "all"
),
'callback'=>array(
"onrename"=>"js:function() { alert('Rename'); }",
"onmove"=>"js:function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { alert('Move id:'+NODE.id+' ref:'+REF_NODE.id+' type:'+TYPE+' rb:'+RB); }",
"oncopy"=>"js:function() { alert('Copy'); }",
"oncreate"=>"js:function() { alert('Create'); }",
"ondelete"=>"js:function() { alert('Delete'); }",
"error"=>"js:function() { }",
"ondblclk"=>"js:function() { alert('Doubleclick'); TREE_OBJ.toggle_branch.call(TREE_OBJ, NODE); TREE_OBJ.select_branch.call(TREE_OBJ, NODE); }",
"onrgtclk"=>"js:function() { alert('Rightclick'); }",
"ondrop"=>"js:function() { alert('Foreign node dropped'); }",
),
));;
?>
And also i have done changing in Cjstree and Behaviour which described on the discussion suction.
can any body tell that what i am doing wrong??