/*----------------------------------
有没有高手做过这样的解决方案?
数据库递归+WCF=>EXT树所需JSON在代码里递归的不算
在代码里递归查询数据库的更不算
要一个简洁的,自治的方案,如上所述数据库表结构大致类似
----------------------------------*/create table TreeMenu(
ID int identity(1,1) primary key,
ParentID int,
Name nvarchar(200),
Url nvarchar(200),
Ex nvarchar(200)
)insert into TreeMenu(ParentID,Name,Url,Ex)
select 0,'根1',null,null union all
select 1,'子1',null,null union all
select 2,'子1',null,null union all
select 3,'子1',null,nullwith temp as(
select * from TreeMenu where ParentID = 0
union all
select TreeMenu.* from TreeMenu,temp where TreeMenu.ParentID=temp.ID
)
select * from temp/*----------------------------------
WCF这里待解,理想的情况是从数据库读取树数据,"高效完美"处理后返回如下JSON格式数据
主要就是在数据库一层和WCF里这一层做处理,返回JSON格式算齐活儿...完美解决方案另赠100分
无完美解决方案均分结贴
----------------------------------*//*----------------------------------
EXT所需树JSON格式大致如下
----------------------------------*/
[   
    {text:'01',children:[   
        {text:'01-01',leaf:true},   
        {text:'01-02',children:[   
            {text:'01-02-01',leaf:true},   
            {text:'01-02-02',leaf:true}   
        ]},   
        {text:'01-03',leaf:true}   
    ]},   
    {text:'02',leaf:true}