sansamael 2011-07-18 14:52:01 4046次浏览 6条回复 0 0 0
<?php 
$this->widget(
  'CTreeView',
  array('url' => array('ajaxTree'),'htmlOptions'=>array('id'=>'treeview','class'=>'treeview treeview-famfamfam'))
);
?>

以上是view页面的代码

public function actionAjaxTree()
{
  if (!Yii::app()->request->isAjaxRequest) {
    exit();
  }
  $parentId = 0;
  if (isset($_GET['id'])) {
    $parentId = (int) $_GET['id'];
  }
  $req = Yii::app()->db->createCommand(
    "SELECT m1.infoClass_id, m1.infoClass_name AS text, m2.infoClass_id IS NOT NULL AS hasChildren "
            . "FROM infoClass_list AS m1 LEFT JOIN infoClass_list AS m2 ON m1.infoClass_id=m2.infoClass_fid "
            . "WHERE m1.infoClass_fid <=> $parentId "
            . "GROUP BY m1.infoClass_id ORDER BY m1.infoClass_name ASC"
  );
  $children = $req->queryAll();
  echo str_replace(
    '"hasChildren":"0"',
    '"hasChildren":false',
    CTreeView::saveDataAsJson($children)
  );
  exit();
}

以上是控制层中的代码。 求解节点信息是怎么传递的,我每次展开都是展开主类,选定的子类节点信息好像没有传过去。

您需要登录后才可以回复。登录 | 立即注册