0
我在Yii框架中使用了CTreeView,因爲我想顯示用戶列表。 所有用戶都顯示在我的樹中,但我想將css添加到正在讀取節點信息的節點。
例如:如果我去用戶/查看/ [id],所有用戶顯示樹而[id]用戶突出顯示 怎麼辦?我想將css添加到正在讀取節點信息的節點
控制器:
public function actionAjaxFillTree()
{
// accept only AJAX request (comment this when debugging)
if (!Yii::app()->request->isAjaxRequest) {
exit();
}
// parse the user input
$parentId = Yii::app()->user->id;
if (isset($_GET['root']) && $_GET['root'] !== 'source') {
$parentId = (int) $_GET['root'];
}
// read the data (this could be in a model)
$children = Yii::app()->db->createCommand(
"SELECT m1.id, m1.username AS text, m2.id IS NOT NULL AS hasChildren "
. "FROM psh_users AS m1 LEFT JOIN psh_users AS m2 ON m1.id=m2.parent_id "
. "WHERE m1.parent_id <=> $parentId "
. "GROUP BY m1.id ORDER BY m1.username ASC"
)->queryAll();
echo str_replace(
'"hasChildren":"0"',
'"hasChildren":false',
CTreeView::saveDataAsJson($children)
);
}
觀點:
<?php
$this->widget(
'CTreeView',
array('url' => array('ajaxFillTree'),
)
);
?>
</div>
讀取裝置。對? –
我不確定,但它可能有助於http://www.yiiframework.com/wiki/215/adding-class-and-links-to-ctreeview-node/ –
@kumar_v不,我有一個用戶列表,當我點擊任何用戶,並進入查看頁面,在視圖(用戶的詳細信息)頁面有一個所有用戶的樹,但我想顯示突出顯示此用戶,我不點擊節點樹, – maryam