pb11.5 web开发 - treeview的使用没有任何问题

 看到很多网友都有使用treeview的问题,而且还有人总是给出一些误导性的回答,特此写了此文证实treeview在web中依然很好用

首先看我的两个treeview:

1、是一个设置功能的:

打开时:

1

 

点开节点

 

2

 

在浏览器里:

 

3

 

2、这个大家应该比较熟

 

4

 

5

 

再来一个treeview的datawindow:

 

6

 

 

 相信大家看到这些,不会再对pb11.5开发web界面上使用treeview有什么可怀疑的了吧

 

部分代码

1、treeview初始化部分

tv_1.deleteitem(0)
dw_function.retrieve()
dw_Action. retrieve()
dw_Status. retrieve()
dw_righttype. retrieve()


long ll_handle
treeviewitem l_tvi

str_function  lstr_function

l_tvi.label="Function"
lstr_function.dec_pid=0
lstr_function.dec_id=0
lstr_function.dw_pcolumn ="0"
lstr_function.dw_column="t_sysfunctionid"
lstr_function.dw_data =  dw_function
lstr_function.label = "fundescription"
l_tvi.data= lstr_function

l_tvi.level=1
l_tvi.children =true
l_tvi.pictureindex=l_tvi.level
l_tvi.statepictureindex=0
ll_handle = tv_1.InsertItemlast(0,l_tvi)
tv_1.expanditem( ll_handle)

l_tvi.label="Action"
lstr_function.dec_pid=0
lstr_function.dec_id=0
lstr_function.dw_pcolumn ="0"
lstr_function.dw_column="t_sysactionid"
lstr_function.dw_data =  dw_Action
lstr_function.label = "actionname"
l_tvi.data= lstr_function

l_tvi.level=1
l_tvi.children =true
l_tvi.pictureindex=l_tvi.level
l_tvi.statepictureindex=0
ll_handle = tv_1.InsertItemlast(0,l_tvi)

l_tvi.label="Status"
lstr_function.dec_pid=0
lstr_function.dec_id=0
lstr_function.dw_pcolumn ="0"
lstr_function.dw_column="t_sysstatusid"
lstr_function.dw_data =  dw_Status
lstr_function.label = "statusname"
l_tvi.data= lstr_function

l_tvi.level=1
l_tvi.children =true
l_tvi.pictureindex=l_tvi.level
l_tvi.statepictureindex=0
ll_handle = tv_1.InsertItemlast(0,l_tvi)

l_tvi.label="Righttype"
lstr_function.dec_pid=0
lstr_function.dec_id=0
lstr_function.dw_pcolumn ="0"
lstr_function.dw_column="t_sysRighttypeid"
lstr_function.dw_data =  dw_righttype
lstr_function.label = "Righttypename"
l_tvi.data= lstr_function

l_tvi.level=1
l_tvi.children =true
l_tvi.pictureindex=l_tvi.level
l_tvi.statepictureindex=0
ll_handle = tv_1.InsertItemlast(0,l_tvi)

 

 

treeview的itempopulate:这个比较长,只贴了部分

long ll_count,i

treeviewitem l_tvi,l_tvichild
str_function lstr_function,lstr_functionchild
datawindow ldw
GetItem(handle,l_tvi )

lstr_function =  l_tvi.data
ldw =lstr_function.dw_data
ldw.retrieve()
choose case l_tvi.level
 case 1
  ll_count=ldw.rowcount()
  for i=1 to ll_count
   l_tvichild.label = ldw.getitemstring(i,lstr_function.label)
   lstr_functionchild.dec_pid=lstr_function.dec_pid
   lstr_functionchild.dec_id=ldw.getitemdecimal(i,lstr_function.dw_column )
   lstr_functionchild.dw_data=lstr_function.dw_data
   lstr_functionchild.dw_column = lstr_function.dw_column
   lstr_functionchild.dw_pcolumn = lstr_function.dw_pcolumn
   
   l_tvichild.data = lstr_functionchild
   l_tvichild.level = l_tvi.level+1
   l_tvichild.pictureindex=l_tvichild.level
   l_tvichild.statepictureindex=0
   if l_tvi.label = "Function" then
    l_tvichild.children=true
   end if
   tv_1.InsertItemLast(handle,l_tvichild)
  next
 case 2  
  if l_tvi.children = false then return
  l_tvichild.level = l_tvi.level+1
  l_tvichild.pictureindex=l_tvichild.level
  l_tvichild.statepictureindex=0
  l_tvichild.children=true
  
  l_tvichild.label = "用户权限"
  lstr_functionchild.dec_pid = ldw.getitemdecimal(1,lstr_function.dw_column )
  lstr_functionchild.dec_id=0
  lstr_functionchild.dw_data=dw_function_user
  lstr_functionchild.dw_pcolumn=lstr_function.dw_column
  lstr_functionchild.dw_column = "t_sysfunction_userid"
  lstr_functionchild.label = "t_sysuser_username"
  l_tvichild.data = lstr_functionchild
  tv_1.InsertItemLast(handle,l_tvichild)
  

2、初始化

//
treeviewitem ltvi_child
long ll_root

This.DeleteItem(0)

ltvi_child.label =  "主菜单"
ltvi_child.data =am_menu
ltvi_child.pictureindex=1
ltvi_child.selectedpictureindex=1
wf_setstate(am_menu,ltvi_child)
if upperbound( am_menu.item) >0 then
 ltvi_child.children =true
end if

ll_root=this.insertitemLast( 0, ltvi_child)
this.ExpandItem ( ll_root )

 

 

itempopulate:

 

menu lm_this
long ll_childcount,i
TreeViewItem ltvi_child,ltvi_this
This.GetItem(handle, ltvi_this)
lm_this = ltvi_this.Data

ll_childcount =upperbound( lm_this.item)
FOR i = 1 TO ll_childcount
 ltvi_child.label =  lm_this.item[i].text
 ltvi_child.data = lm_this.item[i]
 ltvi_child.pictureindex=2
 ltvi_child.selectedpictureindex=2
 if upperbound( lm_this.item[i].item) >0 then
  ltvi_child.children =true
 end if
 wf_setstate( lm_this.item[i],ltvi_child )
 
 this.insertitemLast( handle, ltvi_child) 
NEXT

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值