Home > database >  Consult with pb treeview
Consult with pb treeview

Time:09-26

Use the tree control to display the data, we want the treeview control checkbox is selected according to the beside the dw window, consult how to implement, note: if selected as the parent class, the dw window display only a parent class data, such as selected as a subclass, the dw window display only a subclass of data, the following is the use of part of the event code:
constructor () event:
The integer li_rowcount, li_row
String li_current_dn li_last_dn, li_current_ei li_last_ei, ls_type
//declare two tree view instance variable
Treeviewitem itvi_level_one, itvi_level_two
Long ii_h_l_one
Long ii_h_l_two
Ls_type='office'
Dw_2. Settransobject (sqlca)//dw_2 for implicit data window, beings spanning tree data
Li_rowcount=dw_2. Retrieve (ls_type)//the number of rows
Dw_2. Setsort (" bh, the name ")
Dw_2. Sort ()
//generated tree view of all levels of the tree view item
For li_row=1 to li_rowcount
//
Li_current_dn=dw_2. Object. Bh [li_row]
//dw_2 object "bh category"
Li_current_ei=dw_2. Object. The name [li_row]
//dw_2 object "gkyy_bm name
"If isnull (li_current_ei) then
Li_current_ei=""
End the if

If li_current_dn & lt;> Li_last_dn then
//IF bh and primary view item not repeat
//set the level of the tree view item
Itvi_level_one. Label=dw_2. Object. Dept [li_row]
//view item display information
Itvi_level_one. Level=1 level of//
itvi_level_one.data=https://bbs.csdn.net/topics/li_current_dn
//view of internal information
Itvi_level_one. Pictureindex=1
//not used in the selected icon number
Itvi_level_one. Selectedpictureindex=3
//select the ICONS used in serial number
Itvi_level_one. Children=(li_current_ei & lt;> "')
//under the tree view if there is a level 1
Ii_h_l_one=this. Insertitemlast (0, itvi_level_one)
//item will be added to the level of the tree of the last item on the
End the if
//set the tree view item 2
If li_current_dn & lt;> Li_last_ei then
If li_current_ei & lt;> "' then
Itvi_level_two. Label=dw_2. Object. The name [li_row]
Itvi_level_two. Level=2
itvi_level_two.data=https://bbs.csdn.net/topics/li_current_dn
Itvi_level_two. Pictureindex=2
Itvi_level_two. Selectedpictureindex=4
itvi_level_two.data=https://bbs.csdn.net/topics/li_current_ei
Itvi_level_two. Children=false
Ii_h_l_two=this. Insertitemlast (ii_h_l_one itvi_level_two)
//the last item will be added to the secondary tree
End the if
End the if
Li_last_dn=li_current_dn//set to compare a
Li_last_ei=li_current_ei
Next

ue_synchronizechildren (long handle, integer state) events
Long childitem
Treeviewitem tvitem
The getitem (handle, tvitem)
Tvitem. Statepictureindex=state
Setitem (handle, tvitem)
Childitem=this. Finditem (ChildTreeItem! , handle)
Do the while (childitem<> 1)
This. The Event ue_synchronizechildren (childitem, state)//recursive traversal descendant node
Childitem=this. Finditem (NextTreeItem! The childitem)
Loop
user events ue_synchronizeparent (long handle, integer state)
Long parentitem
Treeviewitem tvitem
The getitem (handle, tvitem)
Tvitem. Statepictureindex=state
Setitem (handle, tvitem)
Parentitem=this. Finditem (ParentTreeItem! , handle)
If parentitem<> 1 then
This. The Event ue_synchronizeparent (parentitem, state)
End the if
user events ue_statechanged (long handle, integer prevstate)
Treeviewitem tvitem
The getitem (handle, tvitem)
If tvitem. Statepictureindex=prevstate then
Return
The else
This. The Event ue_synchronizechildren (handle, tvitem statepictureindex)
If tvitem. Statepictureindex=1 then
This. The Event ue_synchronizeparent (handle, tvitem statepictureindex)
End the if
End the if

Clicked event
Treeviewitem tvitem
The getitem (handle, tvitem)
Post event ue_statechanged (handle, tvitem statepictureindex)

Thank you,,,




CodePudding user response:

Use the tree control to display the data, we want the treeview control checkbox is selected according to the beside the dw window, consult how to implement, note: if selected as the parent class, the dw window display only a parent class data, such as selected as a subclass, the dw window display only a subclass of data, the following is the use of part of the event code


Actually very simple, first determines whether the parent class data and subclasses data source of the same table, fields are the same, if it is possible by setting the setsqlselect (), dynamically created data window and other methods to achieve

Another more stupid way but relatively simple to implement, respectively set up of parent and child classes data window

Through dw_1. DataObject="d_employ" to dynamically set the DataObject

CodePudding user response:

PB with example has similar functionality

CodePudding user response:

General use datastore to associate different levels, to which level, directly in the datastore looking, and, after find out to copy the data window,
Treeviewitem data item or is used to store data of id, again through the window, select the data

CodePudding user response:

I just learned to PB, just don't understand your definition of three events respectively is what function?
The transformation is the icon?

CodePudding user response:

I just saw on the example of
This is written in the OPEN () in the
Integer I, j, li_deptcnt li_empcnt
Long ll_hd_lv1 ll_hd_lv2, ll_root
String ls_deptnm ls_tmp, ls_fn ls_ln, ls_deptid, ls_empid
TreeViewItem ltvi_lv1
DataStore lds_dept, lds_emp


Lds_dept=create datastore
Lds_dept. Dataobject='d_department'
Lds_dept. Settransobject (sqlca)
Lds_dept. Retrieve ()

Lds_emp=create datastore
Lds_emp. Dataobject='d_employee'
Lds_emp. Settransobject (sqlca)
Lds_emp. Retrieve ()

Ll_root=tv_1. FindItem (RootTreeItem! nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related