表:
ID DeviceID SIM
1 3456789 189386
2 345679 1893
3 345679 18944444
4 345 18944444
5 345 189444
6 345 189
最后希望數(shù)據(jù)源格式變成這樣類(lèi)似的形式
var zNodes =[
{ id:1, pId:0, name:"隨意勾選 1", }, //這個(gè)代表DeviceID根節(jié)點(diǎn)
{ id:11, pID:1, name:"189386"},
{ id:2, pId:0, name:"禁止勾選 2"},
{ id:21, pId:2, name:"1893"},
{ id:22, pId:2, name:"18944444"},
{ id:3, pId:0, name:"禁止勾選 2"},
{ id:31, pId:2, name:"18944444"},
{ id:32, pId:2, name:"189444"},
{ id:22, pId:2, name:"1189"}
];
?
對(duì)應(yīng)表個(gè)更節(jié)點(diǎn)就是DeviceID ? ? Sim是對(duì)應(yīng)的 子節(jié)點(diǎn) ?
?我只希望得到這樣的數(shù)據(jù)源格式 就可以了?
后臺(tái)得到 datatable 或者什么都可以 只要格式符合
謝謝 ?!
或者說(shuō)這個(gè)sql怎么寫(xiě) 把DeviceID ? 為345 后面的?18944444 189444 189查出來(lái)變成
? id ? ? ?DeviceID ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SIM
? 3 ? ? ? 345 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?18944444, 189444 ,189
?
我寫(xiě)個(gè)偽游標(biāo)的sql腳本 求大俠幫忙改下
create PROCEDURE tsp
output @@flag
AS
begin
declare @id varchar(20),@userName varchar(20),@password varchar(20),@TableUser varchar(200)
declare cr_cursor cursor --定義游標(biāo)
for select id,DeviceID,SIM from admin
open cr_cursor --打開(kāi)游標(biāo)
fetch From cr_cursor into @id,@DeviceID,@SIM --提取游標(biāo)
while @@fetch_status=0
begin
if(這一次@DeviceID等于上次循環(huán)的@DeviceID)//說(shuō)明DeviceID重復(fù)就字符拼接SIM
{
@flag=@flag+","+@SIM
}else
{
@flag= @SIM
}
最后@flag=@flag+@SIM+@id;//把對(duì)應(yīng)的sim 和id拼接上去
fetch next From cr_cursor into @id,@DeviceID,@SIM
return @flag
end;
close cr_cursor --關(guān)閉游標(biāo)
deallocate cr_cursor --釋放游標(biāo)
end
?
ztree數(shù)據(jù)庫(kù)構(gòu)造的問(wèn)題 大俠幫忙 急 謝謝!
ibeautiful
2018-12-06 21:32:34