JsTree_json异步传值

json数据格式:

[

  {

      /"attributes/" : { /"id/" : /"1/" },

      /"data/" : {/"title/" : /"节点1/",/"attributes/" : { /"href/" :   /"http://jstree.com/" }} ,

      /"state/": /"closed/"

  }

  ,              

  {

      /"attributes/" : { /"id/" : /"2/" },

      /"data/" : {/"title/" : /"节点2/",/"attributes/" : { /"href/" : /"http://2jstree.com/" }},

      /"state/": /"closed/"

  }

]

注:第一个attributes是为节点添加个属性id,这个id可以从前台传过来,用于取该id节点的子节点;

      第二个data是节点数据信息;

      第三个state为closed时表示前台该节点状态为关闭,也只有节点状态为关闭时点击节点会触发异步回传、当state为open时表示前台节点状态为打开,点击时并不会异步回传。

     在后台可以用Request["id"]取到节点id值

下面为前台异步json取节点方法

<script type="text/javascript" class="source">

        $(function() {

            $("#async_json_2").tree({

                data: {

                    type: "json",

                    async: true,

                    opts: {

                        method: "POST",

                        url: "/JsTree/TwoData.aspx" 

                    }

                }

           });//end $(function()

            }); //end $(function()

</script> 

<div class="demo" id="Div1">

 

下面为带子节点的数据格式:

[

  {

    /"attributes/" : { /"id/" : /"1/" },

    /"data/" : {/"title/" : /"Long format demo/",

                /"attributes/" : { /"href/":/"http://jstree.com/" }

               } ,

    /"children/" : [

                     { /"data/" : /"Child node 1/",/"state/": /"closed/" },

                     { /"data/" : /"node 2/" ,/"state/": /"closed/"}

                   ]

   }

,                               

  {

    /"attributes/" : { /"id/" : /"2/" },

    /"data/" : {/"title/" : /"2Long format demo/",

                /"attributes/" : { /"href/" : /"http://2jstree.com/" }

                } ,

    /"state/": /"closed/"

  }

]

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值