落叶 2011-04-28 18:34:06 5152次浏览 8条回复 0 0 0

恩想是用递归

private $_columns;
protected function getCloumns($level,$parentid)
{
  return self::model()->findAll(array(
    'condition'=>'level=:level and parentid=:parentid',
    'params'=>array(':level'=>$level,':parentid'=>$parentid),
  ));
}
	
public function getTreeDropDownList($level,$parentid)
{
  $columns=$this->getCloumns($level, $parentid);
  if(!empty($columns)){
    foreach ($columns as $cl)
    {
      $this->_columns[$cl->columnid]=str_repeat('---', $cl->level-1).$cl->columnname;
      $this->getTreeDropDownList($cl->level+1, $cl->columnid);
    }
  }	
}
	
public function getCl()
{
  $this->getTreeDropDownList(1, 0);
  return $this->_columns;
}

表结构 [attach]128[/attach] 效果图 [attach]129[/attach]

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