Previously, we looked at how to use the Tree Control to filter items in a list. We used custom icons in the tree so that the user had a fast way to determine if they had approved or rejected all of the items within that category. If a red dot was displayed in the node, they knew they still had items to review; a green dot signifies the review for that category was complete, and they didn’t have to spend any more time looking at those items.
The tree control gives you the ability to create a SmartObject (SmO) that contains your own custom icons. This SmO only needs to contain two properties – an ID field and an Image field. I did not make the ID an AutoNumber field because I want to be able to specify what ID I’m assigning to each image so I can use specific values later.
Then create a simple view based on this SmO in order to upload your icon images.
In the Properties for your tree, you can select the Icon Source, and then select the custom icon SmO you created in the step above.
When you configure the data source for each level of the tree by selecting the ellipsis next to Type, you can also set that level’s icon. Selecting “Dynamic” will allow the form to look at the field and value at run time.
For the tree I used as a filter for a list, we wanted to show a red dot for any category that had items that were not reviewed yet, and a green for each category that all items were either Approved or Rejected already. Again, this gave the end user a quick view of what needed to be done yet for this request.
Since we only wanted distinct categories and 1 icon based on the values of multiple rows, a stored procedure was created that gave us that as our data source for the category level of the tree. Here is our query in that stored procedure…
…and the results from the SmartObject Services Tester:
You can see in the icon field that we used 1 (all approved or rejected) or 2 (at least one is still NULL). Now when we use this stored procedure as the data source for the categories in our tree, we can use CATEGORYPATH for what we display, and the icon field will be used to pull the correct ID for our icon in the custom icon SmO we created. CATEGORYID is used for the value of the tree node, and becomes the parameter to send to our list to filter records.