Package org.zkoss.zul

Class Column

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, Component, Scope, ComponentCtrl

    public class Column
    extends HeaderElement
    A single column in a Columns element. Each child of the Column element is placed in each successive cell of the grid. The column with the most child elements determines the number of rows in each column.

    The use of column is mainly to define attributes for each cell in the grid.

    Default getZclass(): z-column. (since 3.5.0)

    Author:
    tomyeh
    See Also:
    Serialized Form
    • Constructor Detail

      • Column

        public Column()
      • Column

        public Column​(java.lang.String label)
      • Column

        public Column​(java.lang.String label,
                      java.lang.String src)
      • Column

        public Column​(java.lang.String label,
                      java.lang.String src,
                      java.lang.String width)
    • Method Detail

      • getGrid

        public Grid getGrid()
        Returns the grid that contains this column.
      • getSortDirection

        public java.lang.String getSortDirection()
        Returns the sort direction.

        Default: "natural".

      • setSortDirection

        public void setSortDirection​(java.lang.String sortDir)
                              throws WrongValueException
        Sets the sort direction. This does not sort the data, it only serves as an indicator as to how the grid is sorted. (unless the grid has "autosort" attribute)

        If you use sort(boolean) to sort rows (Row), the sort direction is maintained automatically. If you want to sort it in customized way, you have to set the sort direction manually.

        Parameters:
        sortDir - one of "ascending", "descending" and "natural"
        Throws:
        WrongValueException
      • getSortAscending

        public java.util.Comparator<?> getSortAscending()
        Returns the ascending sorter, or null if not available.
      • setSortAscending

        public void setSortAscending​(java.util.Comparator<?> sorter)
        Sets the ascending sorter, or null for no sorter for the ascending order.
        Parameters:
        sorter - the comparator used to sort the ascending order. If you are using the group feature, you can pass an instance of GroupComparator to have a better control. If an instance of GroupComparator is passed, GroupComparator.compareGroup(D, D) is used to group elements, and Comparator.compare(T, T) is used to sort elements with a group. Otherwise, Comparator.compare(T, T) is used to group elements and sort elements within a group.
      • setSortAscending

        public void setSortAscending​(java.lang.String clsnm)
                              throws java.lang.ClassNotFoundException,
                                     java.lang.InstantiationException,
                                     java.lang.IllegalAccessException
        Sets the ascending sorter with the class name, or null for no sorter for the ascending order.
        Throws:
        java.lang.ClassNotFoundException
        java.lang.InstantiationException
        java.lang.IllegalAccessException
      • getSortDescending

        public java.util.Comparator<?> getSortDescending()
        Returns the descending sorter, or null if not available.
      • setSortDescending

        public void setSortDescending​(java.util.Comparator<?> sorter)
        Sets the descending sorter, or null for no sorter for the descending order.
        Parameters:
        sorter - the comparator used to sort the descending order. If you are using the group feature, you can pass an instance of GroupComparator to have a better control. If an instance of GroupComparator is passed, GroupComparator.compareGroup(D, D) is used to group elements, and Comparator.compare(T, T) is used to sort elements with a group. Otherwise, Comparator.compare(T, T) is used to group elements and sort elements within a group.
      • setSortDescending

        public void setSortDescending​(java.lang.String clsnm)
                               throws java.lang.ClassNotFoundException,
                                      java.lang.InstantiationException,
                                      java.lang.IllegalAccessException
        Sets the descending sorter with the class name, or null for no sorter for the descending order.
        Throws:
        java.lang.ClassNotFoundException
        java.lang.InstantiationException
        java.lang.IllegalAccessException
      • sort

        public boolean sort​(boolean ascending,
                            boolean force)
        Sorts the rows (Row) based on getSortAscending() and getSortDescending().
        Parameters:
        ascending - whether to use getSortAscending(). If the corresponding comparator is not set, it returns false and does nothing.
        force - whether to enforce the sorting no matter what the sort direction (getSortDirection()) is. If false, this method is the same as sort(boolean).
        Returns:
        whether the rows are sorted.
      • group

        public boolean group​(boolean ascending)
        Groups and sorts the rows (Row) based on getSortAscending(). If the corresponding comparator is not set, it returns false and does nothing.
        Parameters:
        ascending - whether to use getSortAscending(). If the corresponding comparator is not set, it returns false and does nothing.
        Returns:
        whether the rows are grouped.
        Since:
        3.5.0
      • getValue

        public <T> T getValue()
        Returns the value.

        Default: null.

        Note: the value is application dependent, you can place whatever value you want.

        Since:
        3.6.0
      • setValue

        public <T> void setValue​(T value)
        Sets the value.
        Parameters:
        value - the value.

        Note: the value is application dependent, you can place whatever value you want.

        Since:
        3.6.0
      • onGroupLater

        public void onGroupLater​(SortEvent event)
        Internal use only.
        Since:
        6.5.0
      • ungroup

        public void ungroup​(boolean ascending)
        Ungroups and sorts the rows (Row) based on the ascending. If the corresponding comparator is not set, it returns false and does nothing.
        Parameters:
        ascending - whether to use getSortAscending(). If the corresponding comparator is not set, it returns false and does nothing.
        Since:
        6.5.0
      • clone

        public java.lang.Object clone()
        Description copied from interface: Component
        Clones the component. All of its children and descendants are cloned. Also, ID are preserved.
        Specified by:
        clone in interface Component
        Overrides:
        clone in class LabelImageElement
        Returns:
        the new component. Notice that it doesn't belong to any page, nor desktop. It doesn't have a parent, either.