EasyUI 的 combotree 加载数据后折叠起来,并且只允许单击子节点的写法

  $(source).combotree({
            url: '',
             kuan,
            valueField: 'id',
            textField: 'text',
            onlyLeafCheck: true,
            onBeforeSelect: function (node) {
                if (onlyLeaf) {
                    var t = $(this).tree;
                    var isLeaf = t('isLeaf', node.target);
                    if (!isLeaf) {
                        return false;
                    }
                } else {
                    return true;
                }
            },
            onLoadSuccess: function (row, data) {
                $(source).combotree('tree').tree("collapseAll");
            }
        });

自己研究过这个,kuan,是combotree的宽度设置,onlyLeaf表示是否只允许单击子节点,true,表示只允许单击子节点

然后还有个功能,就是 加载成功后,折叠起来

 整体方法,我是这样子的

 function (source, params, kuan, onlyLeaf) {//onlyLeaf 是否只能是子节点单选
        if (kuan == null) kuan = 150;
        $(source).combotree({
            url: '/基本URL?' + params,
             kuan,
            valueField: 'id',
            textField: 'text',
            onlyLeafCheck: true,
            onBeforeSelect: function (node) {
                if (onlyLeaf) {
                    var t = $(this).tree;
                    var isLeaf = t('isLeaf', node.target);
                    if (!isLeaf) {
                        return false;
                    }
                } else {
                    return true;
                }
            },
            onLoadSuccess: function (row, data) {
                $(source).combotree('tree').tree("collapseAll");
            }
        });
    }

  

原文地址:https://www.cnblogs.com/AaronYang/p/3560486.html