获取Jeasyui树层级

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/killgodaa/article/details/84691915
$.extend($.fn.tree.methods, {
    getLevel:function(jq,target){
        var l = $(target).parentsUntil("comboTreeMenu","ul");
        return l.length+1;
    }

 
});
 function selectParentMenu(node){
     $("#parentId").val(node.id);
    var t = $("#comboTreeMenu").combotree('tree');
    var node = t.tree('getSelected');
    var lv =  $().tree("getLevel",node.target);
    $("#level").textbox("setValue",lv);
}

 

 

 

 

 

展开阅读全文

层级树排序展示奇怪问题

05-04

先从简单的一个语句排序来引导,以下语句执行结果排序为啥有差异?rnrn[code=SQL]rnselect * fromrn(rnselect '0-16' as a union select '0-1-6'rn)Trnorder by arn/*rn0-16rn0-1-6rn*/rnrnselect * fromrn(rnselect '0-16' as a union select '0-1-5'rn)Trnorder by arn/*rn0-1-5rn0-16rn*/rn[/code]rnrn[code=SQL]rnCREATE TABLE [Department1](rn [ID] [bigint] NOT NULL,rn [No] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,rn [Name] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,rn [ParentID] [bigint] NULLrn)rnrninsert into [Department1]rnselect 1, 'DNMC', '运营公司', 0 union allrnselect 7, 'OPS', '生产部', 1 union allrnselect 8, 'aaaa', 'aaaa', 1 union allrnselect 9, 'bbbb', 'bbbb', 8 union allrnselect 10, 'cccc', 'cccc', 8 union allrnselect 11, 'ddd', 'dddd', 8 union allrnselect 12, 'vvv', '维修部', 1 union allrnselect 13, '2233', '技术部', 1 union allrnselect 14, 'eeee', 'eeee', 7 union allrnselect 15, 'ffff', 'ffff', 7 union allrnselect 16, 'test', 'test', 0 union allrnselect 17, 'rrrrr', 'rrrr', 7 union allrnselect 18, 'iiii', 'iiii', 10 union allrnselect 28, '33', '经理室', 13 union allrnselect 29, 'test111', 'test222', 1rnrn;with SubTab([Level],[PID],[ID],[No],[Name],[Path]) asrn( rn select 1,[ParentID],[ID],[No],[Name],cast(ltrim(ParentID)+'-'+ltrim(ID) as varchar(4000)) rn from dbo.Department1rn where [ParentID]=0rn union allrn select b.[Level]+1,a.[ParentID],a.[ID],a.[No],a.[Name],cast((b.[Path]+'-'+ltrim(a.[ID])) as varchar(4000))rn from dbo.Department1 a,SubTab brn where a.[ParentID]=b.[ID]rn)rnselect * from SubTab order by [Path]rnrn/*rn1 0 1 DNMC 运营公司 0-1rn2 1 12 vvv 维修部 0-1-12rn2 1 13 2233 技术部 0-1-13rn3 13 28 33 经理室 0-1-13-28rn2 1 29 test111 test222 0-1-29rn[color=#FF0000]1 0 16 test test 0-16[/color]rn2 1 7 OPS 生产部 0-1-7rn3 7 14 eeee eeee 0-1-7-14rn3 7 15 ffff ffff 0-1-7-15rn3 7 17 rrrrr rrrr 0-1-7-17rn2 1 8 aaaa aaaa 0-1-8rn3 8 10 cccc cccc 0-1-8-10rn4 10 18 iiii iiii 0-1-8-10-18rn3 8 11 ddd dddd 0-1-8-11rn3 8 9 bbbb bbbb 0-1-8-9rn*/rnrn;with SubTab([Level],[PID],[ID],[No],[Name],[Path]) asrn( rn select 1,[ParentID],[ID],[No],[Name],cast(ltrim(ParentID)+'->'+ltrim(ID) as varchar(4000)) rn from dbo.Department1rn where [ParentID]=0rn union allrn select b.[Level]+1,a.[ParentID],a.[ID],a.[No],a.[Name],cast((b.[Path]+'->'+ltrim(a.[ID])) as varchar(4000))rn from dbo.Department1 a,SubTab brn where a.[ParentID]=b.[ID]rn)rnselect * from SubTab order by [Path]rn/* 正确结果rn1 0 1 DNMC 运营公司 0->1rn2 1 12 vvv 维修部 0->1->12rn2 1 13 2233 技术部 0->1->13rn3 13 28 33 经理室 0->1->13->28rn2 1 29 test111 test222 0->1->29rn2 1 7 OPS 生产部 0->1->7rn3 7 14 eeee eeee 0->1->7->14rn3 7 15 ffff ffff 0->1->7->15rn3 7 17 rrrrr rrrr 0->1->7->17rn2 1 8 aaaa aaaa 0->1->8rn3 8 10 cccc cccc 0->1->8->10rn4 10 18 iiii iiii 0->1->8->10->18rn3 8 11 ddd dddd 0->1->8->11rn3 8 9 bbbb bbbb 0->1->8->9rn1 0 16 test test 0->16rn*/rn[/code]rn 请各位发表自己的意见,谢谢! 论坛

没有更多推荐了,返回首页