Package org.zkoss.zul

## Interface GroupsModel<D,​H,​F>

- All Known Implementing Classes:
    `AbstractGroupsModel`, `GroupsModelArray`, `SimpleGroupsModel`

      public interface GroupsModel<D,​H,​F>

  The interface defines a suitable data model for grouping `Listbox` and `Grid`.

  H: the class representing a group header, F: the class representing a group footer, and D: the class representing each item of data (in a group).

  If the data model is used with sortable listbox or grid, the developer must also implement `GroupsSortableModel`.

  For more information, please refer to ZK Developer's Reference: Groups Model

  Since:
    3.5.0
  Author:
    tomyeh
  See Also:
    `GroupsSortableModel`, `ListModel`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addGroupsDataListener​(GroupsDataListener l)` | Adds a listener to the groups that's notified each time a change to the data model occurs.
    `boolean` | `addOpenGroup​(int groupIndex)` | Opens the group at the specified index.
    `D` | `getChild​(int groupIndex, int index)` | Returns the child value of the specified group at the specified index.
    `int` | `getChildCount​(int groupIndex)` | Returns the number of children of the specified group.
    `H` | `getGroup​(int groupIndex)` | Returns the group value at the specified index.
    `int` | `getGroupCount()` | Returns the number of groups.
    `F` | `getGroupfoot​(int groupIndex)` | Returns the foot value of the specified group, or null if the specified group does not have any foot.
    `boolean` | `hasGroupfoot​(int groupIndex)` | Returns if the specified group has a foot value.
    `boolean` | `isGroupOpened​(int groupIndex)` | Whether the group is open at the specified index.
    `void` | `removeGroupsDataListener​(GroupsDataListener l)` | Removes a listener from the groups that's notified each time a change to the data model occurs.
    `boolean` | `removeOpenGroup​(int groupIndex)` | Closes the group at the specified index.

- - ### Method Detail

    - #### getGroup

          H getGroup​(int groupIndex)

      Returns the group value at the specified index. It is used to render `Group` and `Listgroup`.
      Parameters:
        `groupIndex` - the index of the group.

    - #### getGroupCount

          int getGroupCount()

      Returns the number of groups.

    - #### getChild

          D getChild​(int groupIndex,
                     int index)

      Returns the child value of the specified group at the specified index.
      Parameters:
        `groupIndex` - the index of the group.
        `index` - the index of the element in the group.

    - #### getChildCount

          int getChildCount​(int groupIndex)

      Returns the number of children of the specified group.

      Note: it does not include the group foot (`getGroupfoot(int)`).

      Parameters:
        `groupIndex` - the index of the group.

    - #### getGroupfoot

          F getGroupfoot​(int groupIndex)

      Returns the foot value of the specified group, or null if the specified group does not have any foot. It is used to render `Groupfoot` and `Listgroupfoot`.

      Note: it is ignored if `hasGroupfoot(int)` returns false.

      Parameters:
        `groupIndex` - the index of the group.

    - #### hasGroupfoot

          boolean hasGroupfoot​(int groupIndex)

      Returns if the specified group has a foot value.
      Parameters:
        `groupIndex` - the index of the group.

    - #### addGroupsDataListener

          void addGroupsDataListener​(GroupsDataListener l)

      Adds a listener to the groups that's notified each time a change to the data model occurs.

    - #### removeGroupsDataListener

          void removeGroupsDataListener​(GroupsDataListener l)

      Removes a listener from the groups that's notified each time a change to the data model occurs.

    - #### isGroupOpened

          boolean isGroupOpened​(int groupIndex)

      Whether the group is open at the specified index. It is used to render `Group` and `Listgroup`.

      Default: true

      Parameters:
        `groupIndex` - the index of the group.
      Since:
        6.0.0

    - #### addOpenGroup

          boolean addOpenGroup​(int groupIndex)

      Opens the group at the specified index.
      Parameters:
        `groupIndex` - the index of the group.
      Returns:
        if it has been added successfully; false if it was opened.
      Since:
        6.0.0

    - #### removeOpenGroup

          boolean removeOpenGroup​(int groupIndex)

      Closes the group at the specified index.
      Parameters:
        `groupIndex` - the index of the group.
      Returns:
        if it has been removed successfully; false if it was closed.
      Since:
        6.0.0