问题描述
我正在开发一个 PHP 项目,在该项目中我使用 Treeview 以 Treeview 格式显示 MysqL 数据一切正常,但我担心的是我想在每个 Treeview 节点上添加右键单击选项,但我不知道该怎么做我做了谷歌,但我没有发现与我的需求相关的任何东西,所以请帮助我如何在 Treeview 上添加右键菜单
Here is my code:
<link rel="stylesheet" type="text/css" href="_styles.css" media="screen">
<?PHP
$con = MysqLi_connect('localhost','root','','modern');
if (MysqLi_connect_errno()) {
echo "Failed to connect to MysqL: " . MysqLi_connect_error();
}
$qry = "SELECT * FROM chart_sheet order by parent ASC";
$result = MysqLi_query($con,$qry);
//$result=MysqL_query($qry);
$arrayCategories = array();
while ($row = MysqLi_fetch_assoc($result)) {
$arrayCategories[$row['chart_sheet_id']] = array("parent_id" => $row['parent_id'],"account_name" =>
$row['account_name'],"closing_account" => $row["closing_account"],"account_no" => $row["account_no"]);
}
//createTree($arrayCategories,0);
function createTree($array,$currentParent,$currLevel = 0,$prevLevel = -1)
{
foreach ($array as $categoryId => $category) {
if ($currentParent == $category['parent_id']) {
if ($currLevel > $prevLevel) echo " <ol class='tree'> ";
if ($currLevel == $prevLevel) echo " </li> ";
if ($currLevel > 0) {
echo '<li> <label-2 for="subfolder2">' . $category['account_name'] . '</label-2> <input type="checkBox" id="subfolder2"/>';
} else {
echo '<li>
<label-1 for="subfolder2">
<span style="color:black">' . $category["account_no"] . '</span>
<span style="color:black">'.$category['account_name'] . '</span>-
<span style="color:red"> ('
. $category['closing_account'] . ')</span>
</label-1> <input type="checkBox" id="subfolder2"/>';
}
if ($currLevel > $prevLevel) {
$prevLevel = $currLevel;
}
$currLeveL++;
createTree($array,$categoryId,$currLevel,$prevLevel);
$currLevel--;
}
}
if ($currLevel == $prevLevel) echo " </li> </ol> ";
}
?>
<div id="content" class="general-style1">
<?PHP
?>
<?PHP
createTree($arrayCategories,0); ?>
<?PHP
?>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)