Source language: Translate to:

HPWTreeView Question

Questions about NeoBook PlugIns

Moderator: Neosoft Support

HPWTreeView Question

Postby David de Argentina » Wed Nov 21, 2012 11:39 am

Hi Hans-Peter,

I'm doing a Outlook Express Clone.

I need to add on execution time some folders into the TreeView Panel.

As each folder has a table into the database, i do this:

1.- Table Structure (Folders)

ID - Autonumeric
Folder - String(50)
Level - numeric
Image1 - Numeric
Image2 - Numeric
Table - String(50)
Order - Numeric (this field is 100, 200, 300, etc, in order to prevent insert childnodes (another folders) 110, 120, 310, 320, etc)

Actual values of the table:

id=1, Folder=NeoOExpress, level=0, image1=0, image2=0, order=100
id=3, Folder=Inbox, Level=1, image1=2, image2=2, order=300
id=8, Folder=Inbox previous 1/1/2012, Level=2, Image1=3, image2=3, order=310
id=4, Folder=Sent, Level=1, Image1=4, image2=4, order=400
id=9, Folder=Sent previous 1/1/2012, Level=2, image1=4, image2=4, order=410
Id=5, Folder=Trash, Level=1, Image1=5, image2=5, order=500
id=6, Folder=WhiteBoard, Level=1, image1=6, image2=6, order=600


2.- Treeview Creation function

Code: Select all
dbpSort "mail" "Folders" "order=ASC"
dbpFirst "mail" "Folders"
loop "1" "[mail.Folders.$RecCount]" "[i]"
  if "[mail.Folders.Level]" "=" "0"
    hpwTreeViewAddNode "TreeView" "[mail.Folders.Folder]" "[mail.Folders.Image1]" "[mail.Folders.Image2]"
  else
    hpwTreeViewAddChildNode "TreeView" "[mail.Folders.Level]" "[mail.Folders.Folder]" "[mail.Folders.Image1]" "[Carpetas.Image2]"
  endif
  dbpNext "mail" "Folders"
endloop


3.- Runtime Right Click Menu actions:

Code: Select all
  Setvar "[NewTable]" ""
  InputBox "New Folder" "Input the name of the new Folder" "[NewTable]"
  if "[NewTable]" ">" ""
    dbpGotoRecord "mail" "Folders" "[TreeView_AbsIndex]"
    SetVar "[Parent_NodeID]" "[mail.Folders.ID]"
    SetVar "[Parent_NodeOrder]" "[mail.Folders.Order]"
    SetVar "[Parent_NodeLevel]" "[mail.Folders.Level]"
    SetVar "[Parent_NodeImage1]" "[mail.Folders.Image1]"
    SetVar "[Parent_NodeImage2]" "[mail.Folders.Image2]"
    dbpAddRecord "mail" "Folders"
    SetVar "[mail.Folders.Folder]" "[NewTable]"
    SetVar "[mail.Folders.Table]" "[NewTable]"
    SetVar "[mail.Folders.Level]" "[Parent_NodeLevel]+1"
    SetVar "[mail.Folders.Image1]" "[Parent_NodeImage1]"
    SetVar "[mail.Folders.Image2]" "[Parent_NodeImage2]"
    SetVar "[mail.Folders.Order]" "[Parent_NodeOrder]+10"
    dbpSaveEdits "mail" "Folders"
    gosub "HPTreeView" (2.-)
  Endif


Both scripts works, but the added nodes allways appair together, under one parent node, not each one under the correct parent node.

Any ideas ?

Thanks in advance,
David de Argentina
User avatar
David de Argentina
 
Posts: 1560
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Re: HPWTreeView Question

Postby HPW » Wed Nov 21, 2012 12:28 pm

Hello,

hpwTreeViewAddChildNode gets a absolute position id where to add the child.
You seems to think that that are the numbers of the top level nodes.
But every node counts in this number.
Look at page 2 of the demo and play with AddNode and AdChildNode with different numbers.

Regards

Hans-Peter
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: HPWTreeView Question

Postby David de Argentina » Wed Nov 21, 2012 4:07 pm

Thanks Hans-Peter,

It works fine now.

Greetings from Buenos Aires
David de Argentina
User avatar
David de Argentina
 
Posts: 1560
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina


Return to PlugIn Discussions

Who is online

Users browsing this forum: No registered users and 3 guests