当前位置: 代码迷 >> PB >> :树型视图代码得不到第3级子节点
  详细解决方案

:树型视图代码得不到第3级子节点

热度:203   发布时间:2016-04-29 10:36:39.0
高手请进:树型视图代码得不到第3级子节点
treeviewitem ltvi_new

integer li_rows,li_cnt
long ll_level0,ll_level1,ll_level2,ll_level3
string ls_paycode0,ls_payname0
string ls_paycode1,ls_payname1
string ls_paycode2,ls_payname2
string ls_paycode3,ls_payname3

//显示数据
dw_base.settransobject(sqlca)
li_rows = dw_base.retrieve()

ls_paycode0 = '13___00000%'

//声明游标
DECLARE cur_list0 CURSOR FOR SELECT weituotable.payname,weituotable.paycode FROM weituotable WHERE (weituotable.paycode like:ls_paycode0) and (weituotable.paycode = '1300000000');
//打开游标
open cur_list0;
//将游标的值赋给变量
fetch cur_list0 into :ls_payname0,:ls_paycode0;

ltvi_new.data = ls_paycode0
ltvi_new.label = ls_payname0
ltvi_new.pictureindex = 2
ltvi_new.selectedpictureindex = 2
ltvi_new.children = true
//在根上插入“记录名称”
ll_level0 = tv_1.insertitemlast(ll_level0,ltvi_new)

//关闭游标
close cur_list0;

ls_paycode1 = '13___00000%'

//声明游标
DECLARE cur_list1 CURSOR FOR SELECT weituotable.payname,weituotable.paycode FROM weituotable WHERE (weituotable.paycode like:ls_paycode1) and (weituotable.paycode <> '1300000000');
//打开游标
open cur_list1;
//将游标的值赋给变量
fetch cur_list1 into :ls_payname1,:ls_paycode1;

ll_level1 = 1

DO WHILE sqlca.sqlcode = 0
ltvi_new.data = ls_paycode1
ltvi_new.label = ls_payname1
  ltvi_new.pictureindex = 2
ltvi_new.selectedpictureindex = 2
ltvi_new.children = true
//插入委托收款单位名称
ll_level2 = tv_1.insertitemlast(ll_level1,ltvi_new)

ls_paycode1 = left(ls_paycode1,5)
//获得委托付款单位名称的编码
ls_paycode1 = ls_paycode1 + "___"
//声明游标
  DECLARE cur_list2 CURSOR FOR SELECT weituotable.payname,weituotable.paycode FROM weituotable WHERE weituotable.paycode LIKE :ls_paycode1 AND weituotable.paycode not like '_____00000';
//打开游标
open cur_list2;
//将游标的值赋给变量
fetch cur_list2 into :ls_payname2,:ls_paycode2;

DO WHILE sqlca.sqlcode = 0
ltvi_new.data = ls_paycode2
ltvi_new.label = ls_payname2
ltvi_new.pictureindex = 2
ltvi_new.selectedpictureindex = 2
ltvi_new.children = true
//在委托收款单位名称下插入付款单位名称
tv_1.insertitemlast(ll_level2,ltvi_new)

//将游标的值赋给变量
fetch cur_list2 into :ls_payname2,:ls_paycode2;

////////////////////////////////////////////////////////////////////////////

ls_paycode2 = left(ls_paycode2,7)
//获得委托付款单位名称的编码
ls_paycode2 = ls_paycode2 + "_____"
//声明游标
  DECLARE cur_list3 CURSOR FOR SELECT weituotable.payname,weituotable.paycode FROM weituotable WHERE weituotable.paycode LIKE :ls_paycode1 AND weituotable.paycode not like '_______000';
//打开游标
open cur_list3;
//将游标的值赋给变量
fetch cur_list3 into :ls_payname3,:ls_paycode3;

DO WHILE sqlca.sqlcode = 0
ltvi_new.data = ls_paycode3
ltvi_new.label = ls_payname3
ltvi_new.pictureindex = 2
ltvi_new.selectedpictureindex = 2
ltvi_new.children = false
//在委托收款单位名称下插入付款单位名称
tv_1.insertitemlast(ll_level3,ltvi_new)
//将游标的值赋给变量
fetch cur_list3 into :ls_payname3,:ls_paycode3;

LOOP
//关闭游标
close cur_list3;

///////////////////////////////////////////////////////////////////////////////


LOOP
//关闭游标
close cur_list2;
  fetch cur_list1 into :ls_payname1,:ls_paycode1;
LOOP
//关闭游标
close cur_list1;

------解决方案--------------------
ll_level3好像没有值吧

修改下面代码试试:
//在委托收款单位名称下插入付款单位名称
ll_level3 = tv_1.insertitemlast(ll_level2,ltvi_new)

------解决方案--------------------
这样写法会出问题的,先用finditem,getitem来获取数据,再用datastore来做数据源,不建议用游标
  相关解决方案