Version: Development 2017.1.1
It displays a TreeView from hierarchical data, pulled from a self-referenced SQLite database table:
-
Create a new Web project in Xojo
-
Copy the webtreeview.sqlite database file next to your new project
-
Copy/Paste the WebTree folder from the sample project imWebTree.xojo_project to your new project
-
Copy/Paste the im module from the sample project to your new project
-
From the WebTree folder, drag & drop a
imWebTreeonto WebPage1 file -
Add an Shown Event Handler to your new imWebTree1 object and add the command
Me.Load_Tree -
In the Session object, add a Public property of type SQLiteDatabase with the name
imDatabase -
Insert a new "Copy Files" Build Step for your current platform. Name it CopyDatabase and drag the database file into the list. For its Behavior choose:
Applies to :
Both
Destination:App Parent Folder -
Add an
OpenEvent Handler to the Session object with the following code:Me.imDatabase = New SQLiteDatabase // open db-file in same folder as app Me.imDatabase.DatabaseFile = GetFolderItem("webtreeview.sqlite") If Not Me.imDatabase.Connect Then Me.imDatabase = Nil Me.MsgBox "Could not connect to database" End If -
Run your project in Xojo
- From the Recordset we fill an Array of type imTreeNode in the right order of appearence of the nodes
- From the array we call the DrawNode method for each imWebTreeNode and store the node in the Rows() Array of the imWebTree object
- Each imWebTreeNode has a RowTag property of type imTreeNode where all its database values are stored
- See imWebTreeNode.DrawNode for details on how each row is drawn
