树形控件

  1. 前端代码

需要用到的插件

 

@{

    Layout = null;

}

 

<!DOCTYPE html>

<html>

<head>

    <meta name="viewport" content="width=device-width" />

    <title>商品分类</title>

    <link href="~/Content/shuxing/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" />

    <script src="~/Content/shuxing/js/jquery-1.4.4.min.js"></script>

    <script src="~/Content/shuxing/js/jquery.ztree.core.js"></script>

    <script type="text/javascript">

        var zTree;

        var setting = {

            view: {

                dblClickExpand: false,

                showLine: true,

                selectedMulti: false

            },

            data: {

                simpleData: {

                    simpleData: {

                        enable: true,

                        idkey: "id",

                        pIdkey: "pId",

                        rootPId: ""

                    }

                },

                callback: {

                    beforeClick: function (treeId, treeNode) {

                        var zTree = $.fn.zTree.getZTreeObj("tree");

                        if (treeNode.isParen) {

                            zTree.expandNode(treeNode);

                            return false;

 

                        } else {

                            return true;

                        }

                    }

                }

 

            }

        };

        var zNodes = [

            { id: 1, pId: 0, name: "超博软件", open: true },

            { id: 101, pId: 1, name: "文胸" },

            { id: 102, pId: 1, name: "香蕉" },

            { id: 103, pId: 1, name: "梨" },

            { id: 10101, pId: 101, name: "红富士苹果" },

            { id: 10102, pId: 101, name: "红星苹果" },

            { id: 10103, pId: 101, name: "红富士苹果" },

            { id: 10104, pId: 101, name: "红星苹果" },

            { id: 10201, pId: 102, name: "红富士苹果" },

            { id: 10202, pId: 101, name: "红星苹果" },

            { id: 10203, pId: 101, name: "红星苹果" },

        ];

        $(document).ready(function () {

            var t = $("#tree");

            t = $.fn.zTree.init(t, setting, zNodes);

        });

 

    </script>

 

</head>

<body class="no-skin">

    <ul id="tree" class="ztree" style="width:260px;overflow:auto;"></ul>

 

    @*导航条*@

</body>

</html>

 

  1. 效果图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值