weixin_33724570 2018-07-26 15:28 采纳率: 0%
浏览 28

简易ui动态树

I am using easy ui tree plugin in my project , currently i am loading the tree using php

<div id="dg" class="easyui-panel" style="padding:5px;"  >
                            <?php
                                $menu = array('items' => array(),'parents' => array());
                                foreach ($results as $items) {
                                    $menu['items'][$items['position']] = $items;
                                    $menu['parents'][$items['immediate_parent']][] = $items['position'];
                                }
                                function buildMenu($parent, $menu)
                                {                                    
                                    $html = "";
                                    if (isset($menu['parents'][$parent])) {
                                        $html .= "
                                            <ul class='easyui-tree' data-options='lines:true'>
";
                                        foreach ($menu['parents'][$parent] as $itemId) {
                                            $pos_val = "\"" . $menu['items'][$itemId]['position'] . "\"";
                                            $checkval = $menu['items'][$itemId]['position'];
                                            if (!isset($menu['parents'][$itemId])) {

                                                $html .= "<li>
 " . ucfirst($menu['items'][$itemId]['Item']) . "" . "<a id='addnode$checkval'style='padding-left:5px;' onclick='addNode(" . $pos_val . ",\"" . $menu['items'][$itemId]['Item'] . "\");' 
                                                    href='javascript:void(0);' title='Add'><i class='fa fa-plus-square' style='color:#2DCB70'></i></a><a onclick='editNode(\"".$menu['items'][$itemId]['id']."\");' href='javascript:void(0);' title='Edit'>
                                                        <i class='fa fa-pencil-square-o'></i></a><a onclick='deleteNode(\"".$menu['items'][$itemId]['id']."\");' href='javascript:void(0);' title='Delete'>
                                                        <i class='fa fa-trash-o'></i></a>";
                                            }
                                            if (isset($menu['parents'][$itemId])) {
                                                $html .= "
                                                    <li><span>" . ucfirst($menu['items'][$itemId]['Item']) . "" . "<a style='padding-left:5px;' onclick='addNode(" . $pos_val . ",\"" . $menu['items'][$itemId]['Item'] . "\");' 
                                                    href='javascript:void(0);'><i class='fa fa-plus-square' style='color:#2DCB70'></i> </a></span>";
                                                $html .= buildMenu($itemId, $menu);
                                                $html .= "</li> 
";
                                            }
                                        }
                                        $html .= "</ul> 
";
                                    }
                                    return $html;
                                }

                                echo buildMenu(0, $menu);
                            ?>
                            </div>

this is the code that i am using. Now i want to load this tree in an ajax page load i dont know how to embedd this code in ajax .

This is the db structure that i am using

enter image description here

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 is not in the mmseg::model registry。报错,模型注册表找不到自定义模块。
    • ¥15 安装quartus II18.1时弹出此error,怎么解决?
    • ¥15 keil官网下载psn序列号在哪
    • ¥15 想用adb命令做一个通话软件,播放录音
    • ¥30 Pytorch深度学习服务器跑不通问题解决?
    • ¥15 部分客户订单定位有误的问题
    • ¥15 如何在maya程序中利用python编写领子和褶裥的模型的方法
    • ¥15 Bug traq 数据包 大概什么价
    • ¥15 在anaconda上pytorch和paddle paddle下载报错
    • ¥25 自动填写QQ腾讯文档收集表