Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    custom treegrid icon based on field value?

    Hi,

    I have reviewed the examples in the Showcase as well as the API doc on

    https://www.smartclient.com/smartgwt.../TreeGrid.html

    but the answer is not obvious to me.

    Can I set up my TreeGrid that uses different icon based on some field value? This is not just to differentiate between Folder and Node, but also between different types of leaf nodes. In other words, if the DS backing the TreeGrid has a field called nodeType, can I set a rule that says if nodeType is A, use iconA.jpg; if B, use iconB.jpg, etc

    I think perhaps I can traverse the tree and then use the setCustomNodeIcon(Record node, String icon) on each node. But are there easier methods?


    I am using SmartClient Version: v10.0p_2016-04-19/PowerEdition Deployment (built 2016-04-19)

    #2
    There is no need to iterate over tree nodes after they have been loaded and call setters. You can simply return Records from your DataSource where the "icon" property is set to the icon you want.

    If you want to use a property other than "icon", this is settable via treeGrid.customIconProperty.

    Comment


      #3
      Ah! That makes sense. I just tried it and it works.

      By the way I also figured out that if I want to use an image distributed with SmartGWT, such as:

      .../sc/skins/Simplicity/images/TreeGrid/file.png

      then I should specify the path as

      "[SKIN]file.png"

      Comment

      Working...
      X