Interface ITreeitem

All Superinterfaces:
IComponent<ITreeitem>, IComposite<ITreeitem,ITreeitemComposite>, IDisable<ITreeitem>, IHtmlBasedComponent<ITreeitem>, IXulElement<ITreeitem>

Immutable Treeitem component

Treeitem contains a row of data (treerow), and an optional treechildren.

If the component doesn't contain a treechildren, it is a leaf node that doesn't accept any child items.

If it contains a treechildren, it is a branch node that might contain other items. For a branch node, an +/- button will appear at the beginning of the row, such that user could open and close the item by clicking on the +/- button.

Support @Action

Name Action Type
onOpen ActionData: OpenData
Denotes user has opened or closed a component. It is useful to implement load-on-demand by listening to the onOpen action, and creating components when the first time the component is opened.
Author:
jumperchen
See Also:
  • Treeitem
  • Field Details

    • DEFAULT

      static final ITreeitem DEFAULT
      Constant for default attributes of this immutable component.
  • Method Details

    • getWidgetClass

      default String getWidgetClass()
      Returns the client widget class.

      Default: "zul.sel.Treeitem"

      Specified by:
      getWidgetClass in interface IComponent<ITreeitem>
    • getWidth

      @Derived @Nullable default String getWidth()
      Description copied from interface: IHtmlBasedComponent
      Returns the width of the component. If not specified, null is assumed.

      Default: null

      Specified by:
      getWidth in interface IHtmlBasedComponent<ITreeitem>
    • withWidth

      default ITreeitem withWidth(@Nullable String width)
      To control the size of Treeitem related components, please refer to ITree and ITreecol instead.
      Specified by:
      withWidth in interface IHtmlBasedComponent<ITreeitem>
      Parameters:
      width - The width of the component.

      Default: null

      Returns:
      A modified copy of the this object
    • getHflex

      @Derived @Nullable default String getHflex()
      Description copied from interface: IHtmlBasedComponent
      Return horizontal flex hint of this component.

      Default: null

      Specified by:
      getHflex in interface IHtmlBasedComponent<ITreeitem>
    • withHflex

      default ITreeitem withHflex(@Nullable String hflex)
      To control the size of Treeitem related components, please refer to ITree and ITreecol instead.
      Specified by:
      withHflex in interface IHtmlBasedComponent<ITreeitem>
      Parameters:
      hflex - The horizontal flex hint.

      Default: null

      Returns:
      A modified copy of the this object
    • withAllComponents

      default ITreeitem withAllComponents(Iterable<? extends ITreeitemComposite> elements)
      Description copied from interface: IComposite
      Copy the current immutable object with elements that replace the content of children. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Specified by:
      withAllComponents in interface IComposite<ITreeitem,ITreeitemComposite>
      Parameters:
      elements - An iterable of children elements to set
      Returns:
      A modified copy of this object
    • getTreerow

      @Nullable ITreerow getTreerow()
      Returns the treerow that this tree item owns (might null). Each tree items has exactly one tree row.
    • withTreerow

      ITreeitem withTreerow(@Nullable ITreerow treerow)
      Returns a copy of this immutable component with the specified treerow.

      Sets the treerow as a child to this component

      Parameters:
      treerow - The treerow child.

      Default: null.

      Returns:
      A modified copy of the this object
    • getTreechildren

      @Nullable ITreechildren getTreechildren()
      Returns the treechildren that this tree item owns, or null if doesn't have any child.
    • withTreechildren

      ITreeitem withTreechildren(@Nullable ITreechildren treechildren)
      Returns a copy of this immutable component with the specified treechildren.

      Sets the treechildren as a child to this component

      Parameters:
      treechildren - The treechildren child.

      Default: null.

      Returns:
      A modified copy of the this object
    • getIndex

      default int getIndex()
      Return the index of this item

      Default: -1, meaning not set

    • withIndex

      ITreeitem withIndex(int index)
      Returns a copy of this immutable component with the specified index.

      Sets the index of this component.

      Parameters:
      index - The index of the child from its parent component.

      Default: -1, meaning not set.

      Returns:
      A modified copy of the this object
    • getImage

      @Nullable default String getImage()
      Returns the image of the first ITreecell it contains.

      Default: null

    • withImage

      ITreeitem withImage(@Nullable String image)
      Returns a copy of this immutable component with the specified image.

      Sets the image of the first ITreecell it contains.

      If treerow and treecell are not created, this method create them automatically.

      Parameters:
      image - The image of the first ITreecell it contains.

      Default: null.

      Returns:
      A modified copy of the this object
    • getLabel

      @Nullable default String getLabel()
      Returns the label of the first ITreecell it contains.

      Default: null

    • withLabel

      ITreeitem withLabel(@Nullable String label)
      Returns a copy of this immutable component with the specified label.

      Sets the label of the first ITreecell it contains.

      If treerow and treecell are not created, this method create them automatically.

      Parameters:
      label - The label of the first ITreecell it contains.

      Default: null.

      Returns:
      A modified copy of the this object
    • isOpen

      default boolean isOpen()
      Returns whether this container is open.

      Default: true.

    • withOpen

      ITreeitem withOpen(boolean open)
      Returns a copy of this immutable component with the specified open.

      Sets whether this container is open.

      Parameters:
      open - false to hide all sublevel items.

      Default: true.

      Returns:
      A modified copy of the this object
    • isSelected

      default boolean isSelected()
      Returns whether this item is selected.

      Default: false

    • withSelected

      ITreeitem withSelected(boolean selected)
      Returns a copy of this immutable component with the specified selected.

      Sets whether the component is selected.

      Parameters:
      selected - true to select this component.

      Default: false.

      Returns:
      A modified copy of the this object
    • isLoaded

      default boolean isLoaded()
      Return true whether all children of this tree item, if any, is loaded at client

      Default: false

    • isSelectable

      default boolean isSelectable()
      Returns whether it is selectable.

      Default: true.

    • isContainer

      @Lazy default boolean isContainer()
      Returns whether the component is to act as a container which can have sublevel items.
    • isEmpty

      @Lazy default boolean isEmpty()
      Returns whether to contain any sublevel tree items or not.
    • withSelectable

      ITreeitem withSelectable(boolean selectable)
      Returns a copy of this immutable component with the specified selectable.

      If the tree is in a checkmark mode, the selectable state will affect the checkable icon to display or not.

      Parameters:
      selectable - false to indicate the checkable icon is not displayed.

      Default: true.

      Returns:
      A modified copy of the this object
    • isRendered

      default boolean isRendered()
      Returns true whether this tree item is rendered at client. Unlike isLoaded() which is used to check whether all children of this tree item are loaded.

      Default: true

    • of

      static ITreeitem of(String label)
      Returns the instance with the given label.
      Parameters:
      label - The label that the first tree cell holds.
    • of

      static ITreeitem of(String label, ITreeitem... items)
      Returns the instance with the given label and all sublevel items.
      Parameters:
      label - The label that the first tree cell holds.
      items - All sublevel items belong to this item
    • of

      static ITreeitem of(String label, Iterable<? extends ITreeitem> items)
      Returns the instance with the given label and all sublevel items.
      Parameters:
      label - The label that the first tree cell holds.
      items - All sublevel items belong to this item
    • ofId

      static ITreeitem ofId(String id)
      Returns the instance with the given id.
      Parameters:
      id - The id to identify this component
    • ofTreerow

      static ITreeitem ofTreerow(ITreerow treerow)
      Returns the instance with the given treerow.
      Parameters:
      treerow - The treerow belongs to this component.
    • ofTreecells

      static ITreeitem ofTreecells(ITreecell<IAnyGroup>... treecells)
      Returns the instance with the given tree cells.
      Parameters:
      treecells - All tree cells belong to this component.
    • ofTreecells

      static ITreeitem ofTreecells(Iterable<? extends ITreecell<IAnyGroup>> treecells)
      Returns the instance with the given tree cells.
      Parameters:
      treecells - All tree cells belong to this component.