Ztree 树插件 树节点名称太长的解决方案

样式允许的情况下 给背景div加滚动条。。

或者使用省略号方法:使用addDiyDom   http://blog.csdn.net/zhengbo0/article/details/17759543

 var setting = {
            view: {
                addDiyDom: addDiyDom
            }
        };

 function addDiyDom(treeId, treeNode) {
            var spaceWidth = 5;
            var switchObj = $("#" + treeNode.tId + "_switch"),
            icoObj = $("#" + treeNode.tId + "_ico");
            switchObj.remove();
            icoObj.parent().before(switchObj);
            var spantxt = $("#" + treeNode.tId + "_span").html();
            if (spantxt.length > 17) {
                spantxt = spantxt.substring(0, 17) + "...";
                $("#" + treeNode.tId + "_span").html(spantxt);
            }
        }

 

 

 

有checkbox时,

 

function addDiyDom(treeId, treeNode) {
            var spaceWidth = 5;
            var switchObj = $("#" + treeNode.tId + "_switch"),
            checkObj = $("#" + treeNode.tId + "_check"),
            icoObj = $("#" + treeNode.tId + "_ico");
            switchObj.remove();
            checkObj.remove();
            icoObj.parent().before(switchObj);
            icoObj.parent().before(checkObj);

            var spantxt = $("#" + treeNode.tId + "_span").html();
            if (spantxt.length > 17) {
                spantxt = spantxt.substring(0, 17) + "...";
                $("#" + treeNode.tId + "_span").html(spantxt);
            }
        
  }

 

posted @ 2016-06-15 17:00  Dene-wang  阅读(6392)  评论(0编辑  收藏  举报