Exercise: Search in a BBjTree
A possible solution is at the end of this page.
Open Exercise-SearchBBjTree.bbj from 04_ExtendedAttributes.zip for the exercise source code.
This exercise for the Extended Attributes chapter consists of a window that contains a tree control and an exit button. The window uses a CSS Grid layout with a single column and two rows. Row 1 holds the tree control and row 2 holds the exit button. The program populates the tree control with all the artists and albums in the CDInventory table of the CDStore database. This creates a tree with a lot of nodes, which makes the tree very tall.
Goals:
-
Prevent the tree control from being too tall for the browser. Set the CSS
max-heightproperty to a pixel value like500px, or to a length like75vh, which means 75% of the viewport height. -
After you limit the display height of the tree, the user must be able to scroll to see the remaining nodes. Set the CSS
overfloworoverflow-yproperty toautoorscroll. -
Customize the BBjTree by adding a search mechanism. Set the
search-inputattribute totrue, as covered in the BBjTree documentation. -
Change the leaf node icons on the tree to compact discs. Set the
icon-leafattribute to an icon, such as the disc icon in the Tabler pool, for exampletabler:disc. See the BBjTree documentation.
Possible solution
The starter file is Exercise-SearchBBjTree.bbj. The solution is in Exercise-SearchBBjTreeComplete.bbj, and you find all files in 04_ExtendedAttributes.zip.