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

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

首先看我的两个treeview:

1、是一个设置功能的:

打开时:

 

点开节点

 

 

在浏览器里:

 

 

2、这个大家应该比较熟

 

 

 

再来一个treeview的datawindow:

 

 

 

 相信大家看到这些,不会再对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

 

你可能感兴趣的:(Web,function,web开发,浏览器,action,menu)