我是用游标查询数据库的
表结构为
父类ID 子ID
SAOO SA01
SA00 SA02
SA01 SA03
SA02 SA04
SA03 SA05
SA05 SA06
我要一步一步把他查出来
做成
SAOO
----SAO1
----SA03
-----SA05
-----SA06
----SA02
----SA04
这样的树状结构
请问如何做
谢谢
4 个解决方案
#1
哈哈。。
算你幸运啦
我也刚做一个这样的功能,可花尽心思了
算你幸运啦
我也刚做一个这样的功能,可花尽心思了
#2
$PBExportHeader$w_test.srw
forward
global type w_test from window
end type
type tv_1 from treeview within w_test
end type
end forward
global type w_test from window
integer x = 498
integer y = 500
integer width = 942
integer height = 1464
boolean titlebar = true
string title = "测试"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 67108864
tv_1 tv_1
end type
global w_test w_test
type variables
long ll_lev1
treeviewitem l_tv1
end variables
forward prototypes
public function long treelist (long tree_handle)
end prototypes
public function long treelist (long tree_handle);treeviewitem l_tvitem
string ls_resourcetype,type_parent
long ll_handle
tv_1.getitem(tree_handle,l_tvitem)
type_parent=string(l_tvitem.label)
//
DECLARE resourcetype CURSOR FOR
SELECT type_child
FROM resource_type
where type_parent=:type_parent
ORDER BY type_child ASC;
open resourcetype;
Fetch resourcetype into :ls_resourcetype;
do while sqlca.sqlcode=0
tv_1.insertitemLast(tree_handle,ls_resourcetype,2)
fetch resourcetype into :ls_resourcetype;
loop
close resourcetype;
//递归列出子类别
long ll_handle1
ll_handle1=tv_1.FindItem(ChildTreeItem!,tree_handle)
do until ll_handle1=-1
treelist(ll_handle1)
ll_handle1=tv_1.FindItem(NextTreeItem!,ll_handle1)
loop
return -1
end function
on w_test.create
this.tv_1=create tv_1
this.Control[]={this.tv_1}
end on
on w_test.destroy
destroy(this.tv_1)
end on
event open;string ls_resourcetype
ll_lev1=tv_1.insertitemFirst(0,"资源类别",1)
//ll_roothandle = l_tv1.finditem(RootTreeItem!,0)
DECLARE resourcetype CURSOR FOR
SELECT type_child
FROM resource_type
where type_class=0
ORDER BY type_child ASC;
open resourcetype;
Fetch resourcetype into :ls_resourcetype;
do while sqlca.sqlcode=0
tv_1.insertitemLast(ll_lev1,ls_resourcetype,2)
fetch resourcetype into :ls_resourcetype;
loop
close resourcetype;
long ll_handle1
ll_handle1=2
do until ll_handle1=-1
treelist(ll_handle1)
ll_handle1=tv_1.FindItem(NextTreeItem!,ll_handle1)
loop
end event
type tv_1 from treeview within w_test
integer width = 741
integer height = 1344
integer taborder = 10
integer textsize = -10
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
borderstyle borderstyle = stylelowered!
long picturemaskcolor = 536870912
long statepicturemaskcolor = 536870912
end type
forward
global type w_test from window
end type
type tv_1 from treeview within w_test
end type
end forward
global type w_test from window
integer x = 498
integer y = 500
integer width = 942
integer height = 1464
boolean titlebar = true
string title = "测试"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 67108864
tv_1 tv_1
end type
global w_test w_test
type variables
long ll_lev1
treeviewitem l_tv1
end variables
forward prototypes
public function long treelist (long tree_handle)
end prototypes
public function long treelist (long tree_handle);treeviewitem l_tvitem
string ls_resourcetype,type_parent
long ll_handle
tv_1.getitem(tree_handle,l_tvitem)
type_parent=string(l_tvitem.label)
//
DECLARE resourcetype CURSOR FOR
SELECT type_child
FROM resource_type
where type_parent=:type_parent
ORDER BY type_child ASC;
open resourcetype;
Fetch resourcetype into :ls_resourcetype;
do while sqlca.sqlcode=0
tv_1.insertitemLast(tree_handle,ls_resourcetype,2)
fetch resourcetype into :ls_resourcetype;
loop
close resourcetype;
//递归列出子类别
long ll_handle1
ll_handle1=tv_1.FindItem(ChildTreeItem!,tree_handle)
do until ll_handle1=-1
treelist(ll_handle1)
ll_handle1=tv_1.FindItem(NextTreeItem!,ll_handle1)
loop
return -1
end function
on w_test.create
this.tv_1=create tv_1
this.Control[]={this.tv_1}
end on
on w_test.destroy
destroy(this.tv_1)
end on
event open;string ls_resourcetype
ll_lev1=tv_1.insertitemFirst(0,"资源类别",1)
//ll_roothandle = l_tv1.finditem(RootTreeItem!,0)
DECLARE resourcetype CURSOR FOR
SELECT type_child
FROM resource_type
where type_class=0
ORDER BY type_child ASC;
open resourcetype;
Fetch resourcetype into :ls_resourcetype;
do while sqlca.sqlcode=0
tv_1.insertitemLast(ll_lev1,ls_resourcetype,2)
fetch resourcetype into :ls_resourcetype;
loop
close resourcetype;
long ll_handle1
ll_handle1=2
do until ll_handle1=-1
treelist(ll_handle1)
ll_handle1=tv_1.FindItem(NextTreeItem!,ll_handle1)
loop
end event
type tv_1 from treeview within w_test
integer width = 741
integer height = 1344
integer taborder = 10
integer textsize = -10
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
borderstyle borderstyle = stylelowered!
long picturemaskcolor = 536870912
long statepicturemaskcolor = 536870912
end type
#3
基本思路为:
先将最顶层的数据取出来,再逐个取父类进行递归计取子类别,看不明的话你给Email给我,我发个例程给你.
先将最顶层的数据取出来,再逐个取父类进行递归计取子类别,看不明的话你给Email给我,我发个例程给你.
#4
兄弟也想看看啊,能把例子发给我吗?
raymen-chen@21cn.com
thank you very much
raymen-chen@21cn.com
thank you very much
#1
哈哈。。
算你幸运啦
我也刚做一个这样的功能,可花尽心思了
算你幸运啦
我也刚做一个这样的功能,可花尽心思了
#2
$PBExportHeader$w_test.srw
forward
global type w_test from window
end type
type tv_1 from treeview within w_test
end type
end forward
global type w_test from window
integer x = 498
integer y = 500
integer width = 942
integer height = 1464
boolean titlebar = true
string title = "测试"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 67108864
tv_1 tv_1
end type
global w_test w_test
type variables
long ll_lev1
treeviewitem l_tv1
end variables
forward prototypes
public function long treelist (long tree_handle)
end prototypes
public function long treelist (long tree_handle);treeviewitem l_tvitem
string ls_resourcetype,type_parent
long ll_handle
tv_1.getitem(tree_handle,l_tvitem)
type_parent=string(l_tvitem.label)
//
DECLARE resourcetype CURSOR FOR
SELECT type_child
FROM resource_type
where type_parent=:type_parent
ORDER BY type_child ASC;
open resourcetype;
Fetch resourcetype into :ls_resourcetype;
do while sqlca.sqlcode=0
tv_1.insertitemLast(tree_handle,ls_resourcetype,2)
fetch resourcetype into :ls_resourcetype;
loop
close resourcetype;
//递归列出子类别
long ll_handle1
ll_handle1=tv_1.FindItem(ChildTreeItem!,tree_handle)
do until ll_handle1=-1
treelist(ll_handle1)
ll_handle1=tv_1.FindItem(NextTreeItem!,ll_handle1)
loop
return -1
end function
on w_test.create
this.tv_1=create tv_1
this.Control[]={this.tv_1}
end on
on w_test.destroy
destroy(this.tv_1)
end on
event open;string ls_resourcetype
ll_lev1=tv_1.insertitemFirst(0,"资源类别",1)
//ll_roothandle = l_tv1.finditem(RootTreeItem!,0)
DECLARE resourcetype CURSOR FOR
SELECT type_child
FROM resource_type
where type_class=0
ORDER BY type_child ASC;
open resourcetype;
Fetch resourcetype into :ls_resourcetype;
do while sqlca.sqlcode=0
tv_1.insertitemLast(ll_lev1,ls_resourcetype,2)
fetch resourcetype into :ls_resourcetype;
loop
close resourcetype;
long ll_handle1
ll_handle1=2
do until ll_handle1=-1
treelist(ll_handle1)
ll_handle1=tv_1.FindItem(NextTreeItem!,ll_handle1)
loop
end event
type tv_1 from treeview within w_test
integer width = 741
integer height = 1344
integer taborder = 10
integer textsize = -10
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
borderstyle borderstyle = stylelowered!
long picturemaskcolor = 536870912
long statepicturemaskcolor = 536870912
end type
forward
global type w_test from window
end type
type tv_1 from treeview within w_test
end type
end forward
global type w_test from window
integer x = 498
integer y = 500
integer width = 942
integer height = 1464
boolean titlebar = true
string title = "测试"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 67108864
tv_1 tv_1
end type
global w_test w_test
type variables
long ll_lev1
treeviewitem l_tv1
end variables
forward prototypes
public function long treelist (long tree_handle)
end prototypes
public function long treelist (long tree_handle);treeviewitem l_tvitem
string ls_resourcetype,type_parent
long ll_handle
tv_1.getitem(tree_handle,l_tvitem)
type_parent=string(l_tvitem.label)
//
DECLARE resourcetype CURSOR FOR
SELECT type_child
FROM resource_type
where type_parent=:type_parent
ORDER BY type_child ASC;
open resourcetype;
Fetch resourcetype into :ls_resourcetype;
do while sqlca.sqlcode=0
tv_1.insertitemLast(tree_handle,ls_resourcetype,2)
fetch resourcetype into :ls_resourcetype;
loop
close resourcetype;
//递归列出子类别
long ll_handle1
ll_handle1=tv_1.FindItem(ChildTreeItem!,tree_handle)
do until ll_handle1=-1
treelist(ll_handle1)
ll_handle1=tv_1.FindItem(NextTreeItem!,ll_handle1)
loop
return -1
end function
on w_test.create
this.tv_1=create tv_1
this.Control[]={this.tv_1}
end on
on w_test.destroy
destroy(this.tv_1)
end on
event open;string ls_resourcetype
ll_lev1=tv_1.insertitemFirst(0,"资源类别",1)
//ll_roothandle = l_tv1.finditem(RootTreeItem!,0)
DECLARE resourcetype CURSOR FOR
SELECT type_child
FROM resource_type
where type_class=0
ORDER BY type_child ASC;
open resourcetype;
Fetch resourcetype into :ls_resourcetype;
do while sqlca.sqlcode=0
tv_1.insertitemLast(ll_lev1,ls_resourcetype,2)
fetch resourcetype into :ls_resourcetype;
loop
close resourcetype;
long ll_handle1
ll_handle1=2
do until ll_handle1=-1
treelist(ll_handle1)
ll_handle1=tv_1.FindItem(NextTreeItem!,ll_handle1)
loop
end event
type tv_1 from treeview within w_test
integer width = 741
integer height = 1344
integer taborder = 10
integer textsize = -10
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
borderstyle borderstyle = stylelowered!
long picturemaskcolor = 536870912
long statepicturemaskcolor = 536870912
end type
#3
基本思路为:
先将最顶层的数据取出来,再逐个取父类进行递归计取子类别,看不明的话你给Email给我,我发个例程给你.
先将最顶层的数据取出来,再逐个取父类进行递归计取子类别,看不明的话你给Email给我,我发个例程给你.
#4
兄弟也想看看啊,能把例子发给我吗?
raymen-chen@21cn.com
thank you very much
raymen-chen@21cn.com
thank you very much