Hi
I wat to implement CTreeView which will represent 2 models. It should be plain tree, where every node can have many leafs - these leafs don’t have leafs.
Model ‘Sectors’ has nodes, model ‘SubSectors’ are leafs.
For example Sector BANKING:
CTreeView :
This tree should function in the way, that if I click on any leaf, its value should propagate to corresponding textarea. Textarea also will have rows/lines functionality to enable deleting selected rows. Textarea values will be used for search.
In controller which renders the search site as far as I know I have to load models which are used on the search site:
$this->render('search',array(
'model1'=>$model1,
'model2'=>$model2
));
Then in search.php view I can access model1 and model2.
Now let’s assume model1 is my Sectors (nodes) model. Model2 is SubSectors (leafs). How to implement tree with such structure? Not many info found on forums. Should I have relations defined in models to do this?
I found similar topic here the code works, but it uses static defined tree.
Data for tree and leafs is being fetched from function:
protected function getData()
{
$data=array(
array("id"=>1,"name"=>"John","parents"=>
array(
array("id"=>10,"name"=>"Mary","parents"=>
array(
array("id"=>100,"name"=>"Jane","parents"=>
array(
array("id"=>1000,"name"=>"Helene",),
array("id"=>1001,"name"=>"Peter",),
)
)
)
)
)
..
..
..
return $data;
This above is nested tree, where node has leafs, leafs can have own leafs:
In my case I need just nodes, and leafs. Leafs don’t have leafs.
So static code for my needs would look like:
<?php
function getData{
$data=array(
array("id"=>1,"name"=>"John","parents"=>
array(
array("id"=>10,"name"=>"Mary")
array("id"=>11,"name"=>"Lary")
)
)
array("id"=>2,"name"=>"Jane","parents"=>
array(
array("id"=>20,"name"=>"Hary")
array("id"=>21,"name"=>"Wary")
)
)
)
...........
.........
.....
return $data;
?>
}
How to get data from 2 models instead of writing static function?
Thank you in advance