• jstree 使用API


    beforechange: function() { log("About to change"); return true },        

    beforeopen : function() { log("About to open"); return true },        

    beforeclose : function() { log("About to close"); return true },        

    beforemove : function() { log("About to move"); return true },        

    beforecreate: function() { log("About to create"); return true },        

    beforerename: function() { log("About to rename"); return true },        

    beforedelete: function() { log("About to delete"); return true },        

    onselect : function() { log("Select"); },        

    ondeselect : function() { log("Deselect"); },        

    onchange : function() { log("Focus changed"); },        

    onrename : function() { log("Rename"); },        

    onmove : function() { log("Move"); },        

    oncopy : function() { log("Copy"); },        

    oncreate : function() { log("Create"); },        

    ondelete : function() { log("Delete"); },        

    onopen : function() { log("Open"); },        

    onopen_all : function() { log("Open ALL"); },        

    onclose : function() { log("Close"); },        

    error : function() { },        

    ondblclk : function() { log("Doubleclick");

    TREE_OBJ.toggle_branch.call(TREE_OBJ, NODE);

    TREE_OBJ.select_branch.call(TREE_OBJ, NODE); },        

    onrgtclk : function() { log("Rightclick"); },        

    onload : function() { log("Tree loaded"); },        

    onfocus : function() { log("Tree got focus"); },        

    ondrop : function() { log("Foreign node dropped"); }

     

    $("#Organizediv").jstree({
                            "plugins": ["thems", "html_data", "ui", "crrm", "cookies", "dnd", "search", "types", "hotkeys", "contextmenu"],
                            "types": {
                                "types": {
                                    "department": {
                                        "valid_children": ["department", "root"],
                                        "icon": { "image": "/Images/report_user.png" }
                                    },
                                    "root": {
                                        "valid_children": ["department", "root"],
                                        "icon": { "image": "/Images/skysolar_logo.png" },
                                        "remove": false
                                    }
                                }
                            }
                        })

    .bind("select_node.jstree", function (event, data) {
                    if (data.rslt.obj.attr("id") != undefined) {
                        var Url = window.location.href.toLowerCase();
                        var id = data.rslt.obj.attr("id").toString();
                    }
    })

    //createnode
                     .bind("create.jstree", function (e, data) {
                         var createdata = "{";
                         createdata += '"organizeName":"' + data.rslt.name + '"';
                         createdata += ',"parentID":' + parseInt(data.rslt.parent.attr("id").replace("li_", ""));
                         createdata += "}";
                         $.ajax({
                             type: "post",
                             url: "/WCF/UserService.svc/AddOrganization",
                             contentType: "text/json;charset=utf-8",
                             data: createdata,
                             success: function (data1) {
                                 var id = parseInt(data1.d);
                                 $(data.rslt.obj).attr("id", "li_" + data1.d);
                             },
                             error: function () {
                                 alert("Create Failure.");
                                 $.jstree.rollback(data.rlbk);
                             }
                         })

                     })//remove node
                     .bind("remove.jstree", function (e, data) {
                         data.rslt.obj.each(function () {
                             var removedata = '{"ids":' + this.id.replace("li_", "") + '}';
                             $.ajax({
                                 type: "post",
                                 url: "/WCF/UserService.svc/DeleteOrganize",
                                 contentType: "text/json;charset=utf-8",
                                 data: removedata,
                                 success: function (r) {
                                     alert(r.d);
                                     if (r.d != "Delete Success") {
                                         $.jstree.rollback(data.rlbk);
                                     }
                                 },
                                 error: function () {
                                     alert("Remove Failure.");
                                     $.jstree.rollback(data.rlbk);
                                 }
                             });
                         });
                     })
                        //rename
                     .bind("rename.jstree", function (e, data) {
                         var id = parseInt(data.rslt.obj.attr("id").replace("li_", ""));
                         var newName = data.rslt.new_name;
                         if (newName != "" && newName != undefined) {
                             var renamedata = '{"id":' + id + ',"newName":"' + newName + '"}';
                             $.ajax({
                                 type: "post",
                                 url: "/WCF/UserService.svc/RenameOrganization",
                                 contentType: "text/json;charset=utf-8",
                                 data: renamedata,
                                 success: function (r) {
                                 },
                                 error: function () {
                                     $.jstree.rollback(data.rlbk);
                                 }
                             });
                         }

                     })
                        //move
                     .bind("move_node.jstree", function (e, data) {
                         data.rslt.o.each(function (i) {
                             var id = parseInt(this.id.replace("li_", ""));
                             var newparentid = 0;
                             if (data.rslt.np.attr("id") != "Organizediv") {
                                 newparentid = parseInt(data.rslt.np.attr("id").replace("li_", ""));
                             }
                             var index = parseInt($("#" + this.id).parent().children().index($("#" + this.id)));
                             var movedata = '{' + '"id":' + id + ',"newParentId":' + newparentid + ',"index":' + index + '}';
                             $.ajax({
                                 type: "post",
                                 url: "/WCF/UserService.svc/SortOrganize",
                                 contentType: "text/json;charset=utf-8",
                                 data: movedata,
                                 success: function (r) {
                                 },
                                 error: function () {
                                     alert("Move Failure.");
                                     $.jstree.rollback(data.rlbk);
                                 }
                             });
                         });
                     });

  • 相关阅读:
    windows使用pipenv创建虚拟环境报错UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 4: in...
    mysql监控工具sqlprofiler,类似sqlserver的profiler工具安装(一)
    [转]linux awk命令详解
    navicat for mysql 如何设置字段唯一
    linux硬链接与软链接
    linux后台运行和关闭、查看后台任务
    测试覆盖率的基本策略
    【Unity Shader】二、顶点函数(vertex)和片元函数(fragment)传递数据,及各阶段可使用的语义(semantic)
    【Unity Shader】一、顶点函数(vertex)和片元函数(fragment)
    Unity Shader学习资料
  • 原文地址:https://www.cnblogs.com/netact/p/2201962.html
Copyright © 2020-2023  润新知