Ctreeview Don't Show Data

I’m new in Yii and I want work with CTreeView, but CTreeView don’t show data.

I create in MySql the table Tree (id, text, parent_id).

I create the CRUD forms for Tree table. The forms are ok.

I write in index.php this code:

<?php

$this->widget(

'CTreeView',


array('url' =&gt; array('ajaxFillTree'))

);

?>

I write in the TreeController.php this code:

/**


 * Fills the JS tree on an AJAX request.


 * Should receive parent node ID in &#036;_GET['root'],


 *  with 'source' when there is no parent.


 */


public function actionAjaxFillTree()


{


	Yii::app()-&gt;user-&gt;setFlash('success', 'Entrem a actionAjaxFillTree&#33;');


	// accept only AJAX request (comment this when debugging)


	if (&#33;Yii::app()-&gt;request-&gt;isAjaxRequest) {


		Yii::app()-&gt;user-&gt;setFlash('success', 'Error a actionAjaxFillTree&#33;');


		exit();


	}





	// read the data (this could be in a model)


	&#036;children = Yii::app()-&gt;db-&gt;createCommand(


			&quot;SELECT m1.id, m1.name AS text, m2.id IS NOT NULL AS hasChildren &quot;


			. &quot;FROM tree AS m1 LEFT JOIN tree AS m2 ON m1.id=m2.parent_id &quot;


			. &quot;GROUP BY m1.id ORDER BY m1.name ASC&quot;


	)-&gt;queryAll();


	echo str_replace(


			'&quot;hasChildren&quot;:&quot;0&quot;',


			'&quot;hasChildren&quot;:false',


			CTreeView::saveDataAsJson(&#036;children)


	);


}

The index.php/tree/admin show values in the grid, but I don’t see CTreeView in the form.

Can you help to me?

Thanks.

Dani

If it is not displaying result then please check a query for that first. Might be there is any issue in a joining.