mahuiqiao
心殇竹墨轩
采纳率0%
2016-05-31 06:30 阅读 1.7k

jstree如何做树形菜单时mysql中的sql语句该怎么写

我的jstree代码如下:
href="/static/manage/js/jstree/themes/default/style.min.css">

$('#jstree_demo') .jstree( { "core" : { "animation" : 0, "check_callback" : true, "themes" : { "stripes" : true }, 'data' : { 'url' : function(node) { var jsonData = JSON.stringify(node); alert(jsonData); return node.id === '#' ? '/manage/competence/getCPList?parentId=-1' : '/manage/competence/getCPList'; }, 'data' : function(node) { return { 'id' : node.id }; } } }, "types" : { "#" : { "max_children" : 1, "max_depth" : 4, "valid_children" : [ "root" ] }, "root" : { "icon" : "/static/manage/js/jstree/themes/images/tree_icon.png", "valid_children" : [ "default" ] }, "default" : { "valid_children" : [ "default", "file" ] }, "file" : { "icon" : "glyphicon glyphicon-file", "valid_children" : [] } }, "plugins" : [ "contextmenu", "dnd", "search", "state", "types", "wholerow" ] }); $('#jstree_demo').on("changed.jstree", function(e, data) { if (data.selected != "") { console.log(data.selected); //alert(data.selected); changeCompetence(data.selected); window.location.href='/manage/competence/index.htm#'+data.selected } });

请教大神帮忙看看,因为我数据库中的id必须要个这个node.id一致,不知道改则呢么改了

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • motherland_hope 斯密德 2016-05-31 10:08

    大概思路应该是:迭代算法,
    可以在mysql中定义一个函数,函数的参数为节点,根据你传入的节点来判定是否有子节点,然后再判定子节点下是否有子子节点,,,,,,,,大概是这个思路

    点赞 评论 复制链接分享

相关推荐