how to implement treeview, data coming from db

I have this table:

CREATE TABLE ACCOUNT_TYPE

( "ACCOUNT_TYPE_UID" NUMBER PRIMARY KEY,

"ACCOUNT_TYPE_PARENT_UID" NUMBER, 


"DESCRIPTION" VARCHAR2(100 BYTE), 

)

ALTER TABLE ACCOUNT_TYPE

ADD CONSTRAINT ACCOUNT_TYPE FOREIGN KEY ("ACCOUNT_TYPE_PARENT_UID")

   REFERENCES ACCOUNT_TYPE ("ACCOUNT_TYPE_UID") ENABLE

And it has this data:

ACCOUNT_TYPE_UID ACCOUNT_TYPE_PARENT_UID DESCRIPTION


        1                 NULL                             ASSETS                


        2                 NULL                             LIABILITIES


        3                 NULL                             EQUITY


        4                 NULL                             INCOME


        5                 NULL                             EXPENSES


        6                 1                                Current Assets


        7                 6                                Cash

in my view/index.php

<?php

$this->widget(‘CTreeView’,

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


);   	

?>

while in my AccountTypeController

public function actionAjaxFillTree()

{


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


        exit();


    }


    //&#036;parentId = &quot;NULL&quot;;


    if (isset(&#036;_GET['root']) &amp;&amp; &#036;_GET['root'] &#33;== 'source') {


        &#036;parentId = (int) &#036;_GET['root'];


    }


    &#036;sql =  &quot;SELECT m1.ACCOUNT_TYPE_UID, m1.description, &quot;


			. &quot; DECODE(m1.account_type_parent_uid, NULL, 1, 0 ) hasChildren &quot;


			. &quot; FROM ACCOUNT_TYPE_101 m1 &quot;


			. &quot; LEFT OUTER JOIN ACCOUNT_TYPE_101 m2 &quot;


			. &quot; ON m1.account_type_parent_uid = m2.account_type_uid &quot;


			. &quot;WHERE m1.account_type_parent_uid &lt;=&gt; &#036;parentId &quot;


			. &quot; ORDER BY m1.sequence; &quot; ;


   


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


			


    &#036;children = &#036;req-&gt;queryAll();


    


    echo str_replace(


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


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


        CTreeView::saveDataAsJson(&#036;children)


    );        


    exit();                


}

but no treeview is being render in the output?

what is wrong/missing in my code?

much need your help guys…

thanks in advance

Hi,

maybe this extension can help you, for me it worked fine:

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

Hi Kabinenkoffer,

I try to run this extension you mentioned. Unfortunately without success, just the same issue as in the comments: No interactivity with the DB. Could you please be so kind and give me a hint how you were able to run this thing?

My settings so far:

in the Site Controller:

in the view/site/index:

The Table:

Is it necessary to fill the table with values?

Beste Grüße

Norbert

A question beginning with "how to" is surely not a feature request. Wrong forum.

NOTE: moved to proper section (General Discussion for Yii 1.1.x instead of Feature request)

The ORACLE query return ALL CAPS array keys but the CTreeView::saveDataAsJson($data) needs a valid array data which has the keys: id, text, and hasChildren.

Check CTreeView valid DATA.

So I use this line of code to rename the array keys:

Then I changed the query into this:

I hope this will help.