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'=>array('accountType/ajaxFillTree'))
);
?>
while in my AccountTypeController
public function actionAjaxFillTree()
{
if (!Yii::app()->request->isAjaxRequest) {
exit();
}
//$parentId = "NULL";
if (isset($_GET['root']) && $_GET['root'] !== 'source') {
$parentId = (int) $_GET['root'];
}
$sql = "SELECT m1.ACCOUNT_TYPE_UID, m1.description, "
. " DECODE(m1.account_type_parent_uid, NULL, 1, 0 ) hasChildren "
. " FROM ACCOUNT_TYPE_101 m1 "
. " LEFT OUTER JOIN ACCOUNT_TYPE_101 m2 "
. " ON m1.account_type_parent_uid = m2.account_type_uid "
. "WHERE m1.account_type_parent_uid <=> $parentId "
. " ORDER BY m1.sequence; " ;
$req = Yii::app()->db->createCommand($sql);
$children = $req->queryAll();
echo str_replace(
'"hasChildren":"0"',
'"hasChildren":false',
CTreeView::saveDataAsJson($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