Class Pivottable

  • All Implemented Interfaces:
    Serializable, Cloneable, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.ext.Scope, org.zkoss.zk.ui.sys.ComponentCtrl, org.zkoss.zul.ext.Pageable

    public class Pivottable
    extends org.zkoss.zul.impl.XulElement
    implements org.zkoss.zul.ext.Pageable
    Pivottable component. The component takes a PivotModel to populate data.
    Author:
    jumperchen / simonpai
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlBasedComponent

        org.zkoss.zk.ui.HtmlBasedComponent.ExtraCtrl
      • Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent

        org.zkoss.zk.ui.AbstractComponent.Children, org.zkoss.zk.ui.AbstractComponent.ForwardInfo, org.zkoss.zk.ui.AbstractComponent.TargetInfo
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String COLUMN_TITLE  
      static String DATA_TITLE  
      static String ROW_TITLE  
      static String SCROLL_POS  
      • Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent

        _zclass
      • Fields inherited from interface org.zkoss.zk.ui.Component

        APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
      • Fields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl

        AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, AFTER_PARENT_CHANGED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE
    • Constructor Summary

      Constructors 
      Constructor Description
      Pivottable()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean addTitleCell​(String type, org.zkoss.zk.ui.Component component)
      Add component in title cells
      void beforeChildAdded​(org.zkoss.zk.ui.Component newChild, org.zkoss.zk.ui.Component refChild)  
      void clearCustomSizes()
      Clear custom sizes adjusted by user.
      Object clone()  
      int getActivePage()
      Returns the active page (starting from 0).
      org.zkoss.zk.ui.Component getColumnCell()
      Return the component in column title cell.
      org.zkoss.zk.ui.Component getDataCell()
      Return the component in data title cell.
      String getDataFieldOrient()
      Return the value of data field orientation.
      PivotModel getModel()
      Returns pivot model.
      int getPageCount()
      Returns the number of pages.
      int getPageSize()
      Returns the number of items per page.
      PivotRenderer getPivotRenderer()
      Returns the pivot renderer.
      org.zkoss.zk.ui.Component getRowCell()
      Return the component in row title cell.
      int getTotalSize()
      Returns the total number of items.
      String getZclass()  
      boolean insertBefore​(org.zkoss.zk.ui.Component newChild, org.zkoss.zk.ui.Component refChild)  
      void invalidate()
      Invalidates the pivottable, causing it to rerender.
      boolean isAutowrap()
      Gets whether auto wrap the content and adjust row height.
      boolean isChildable()  
      boolean isFrozenColumnHeaders()
      boolean isGrandTotalForColumns()
      Returns whether enables to show the grand total for columns.
      boolean isGrandTotalForRows()
      Returns whether enables to show the grand total for rows.
      void onChildRemoved​(org.zkoss.zk.ui.Component child)  
      void onInitRender​(org.zkoss.zk.ui.event.Event event)
      Only internal use to prepare the rendering information from the pivot model.
      protected void renderProperties​(org.zkoss.zk.ui.sys.ContentRenderer renderer)  
      void service​(org.zkoss.zk.au.AuRequest request, boolean everError)  
      void sessionDidActivate​(org.zkoss.zk.ui.Page page)  
      void sessionWillPassivate​(org.zkoss.zk.ui.Page page)  
      void setActivePage​(int pg)
      Set the active page
      void setAutowrap​(boolean autowrap)
      Sets whether auto wrap the content and adjust row height Note: It is strongly recommended NOT to use autowrap if there are huge amount of cells in one page or the performance at client side might be horrible.
      void setDataFieldOrient​(String orient)
      Set the orientation of data fields, which determines how data are arranged on the Pivottable when there are more than one data fields.
      void setFrozenColumnHeaders​(boolean frozenColumnHeaders)
      Enable frozen column headers.
      void setGrandTotalForColumns​(boolean grandTotalForColumns)
      Sets whether enables to show the grand total for columns.
      void setGrandTotalForRows​(boolean grandTotalForRows)
      Sets whether enables to show the grand total for rows.
      void setHeight​(String height)  
      void setModel​(PivotModel model)
      Sets the pivot model.
      void setPageSize​(int size)
      Sets the items to show in each page
      void setPivotRenderer​(PivotRenderer renderer)
      Sets the pivot renderer
      • Methods inherited from class org.zkoss.zul.impl.XulElement

        getContext, getCtrlKeys, getPopup, getPropertyAccess, getTooltip, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributes
      • Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent

        addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getExtraCtrl, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, removeSclass, removeSclass, setAction, setClass, setClientAction, setDraggable, setDroppable, setFocus, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly
      • Methods inherited from class org.zkoss.zk.ui.AbstractComponent

        addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildRemoved, beforeParentChanged, destroyIndexCacheMap, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, disableHostChanged, enableBindingAnnotation, enableHostChanged, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getForwards, getId, getIndexCacheMap, getLastChild, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onPageAttached, onPageDetached, onParentChanged, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderPropertiesOnly, replace, response, response, response, service, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
    • Constructor Detail

      • Pivottable

        public Pivottable()
    • Method Detail

      • setHeight

        public void setHeight​(String height)
        Overrides:
        setHeight in class org.zkoss.zk.ui.HtmlBasedComponent
      • getPageSize

        public int getPageSize()
        Returns the number of items per page.

        Default: 20.

        Specified by:
        getPageSize in interface org.zkoss.zul.ext.Pageable
      • setPageSize

        public void setPageSize​(int size)
                         throws org.zkoss.zk.ui.WrongValueException
        Sets the items to show in each page
        Specified by:
        setPageSize in interface org.zkoss.zul.ext.Pageable
        Throws:
        org.zkoss.zk.ui.WrongValueException
      • getTotalSize

        public int getTotalSize()
        Returns the total number of items.
      • getPageCount

        public int getPageCount()
        Returns the number of pages. Note: there is at least one page even no item at all.
        Specified by:
        getPageCount in interface org.zkoss.zul.ext.Pageable
      • getActivePage

        public int getActivePage()
        Returns the active page (starting from 0).
        Specified by:
        getActivePage in interface org.zkoss.zul.ext.Pageable
      • setActivePage

        public void setActivePage​(int pg)
                           throws org.zkoss.zk.ui.WrongValueException
        Set the active page

        Note: In server side, active page starts from 0. But in browser UI, it starts from 1

        Specified by:
        setActivePage in interface org.zkoss.zul.ext.Pageable
        Throws:
        org.zkoss.zk.ui.WrongValueException
      • setGrandTotalForRows

        public void setGrandTotalForRows​(boolean grandTotalForRows)
        Sets whether enables to show the grand total for rows.

        Default: true

      • isGrandTotalForRows

        public boolean isGrandTotalForRows()
        Returns whether enables to show the grand total for rows.

        Default: true.

      • setGrandTotalForColumns

        public void setGrandTotalForColumns​(boolean grandTotalForColumns)
        Sets whether enables to show the grand total for columns.

        Default: true

      • isGrandTotalForColumns

        public boolean isGrandTotalForColumns()
        Returns whether enables to show the grand total for columns.

        Default: true.

      • getDataCell

        public org.zkoss.zk.ui.Component getDataCell()
        Return the component in data title cell.
      • getColumnCell

        public org.zkoss.zk.ui.Component getColumnCell()
        Return the component in column title cell.
      • getRowCell

        public org.zkoss.zk.ui.Component getRowCell()
        Return the component in row title cell.
      • beforeChildAdded

        public void beforeChildAdded​(org.zkoss.zk.ui.Component newChild,
                                     org.zkoss.zk.ui.Component refChild)
        Specified by:
        beforeChildAdded in interface org.zkoss.zk.ui.sys.ComponentCtrl
        Overrides:
        beforeChildAdded in class org.zkoss.zk.ui.AbstractComponent
      • onChildRemoved

        public void onChildRemoved​(org.zkoss.zk.ui.Component child)
        Specified by:
        onChildRemoved in interface org.zkoss.zk.ui.sys.ComponentCtrl
        Overrides:
        onChildRemoved in class org.zkoss.zk.ui.AbstractComponent
      • insertBefore

        public boolean insertBefore​(org.zkoss.zk.ui.Component newChild,
                                    org.zkoss.zk.ui.Component refChild)
        Specified by:
        insertBefore in interface org.zkoss.zk.ui.Component
        Overrides:
        insertBefore in class org.zkoss.zk.ui.AbstractComponent
      • getDataFieldOrient

        public String getDataFieldOrient()
        Return the value of data field orientation. Can only be column or row.
      • setDataFieldOrient

        public void setDataFieldOrient​(String orient)
        Set the orientation of data fields, which determines how data are arranged on the Pivottable when there are more than one data fields.
        Parameters:
        orient - accepts either column or row. Throws an exception otherwise.
      • clearCustomSizes

        public void clearCustomSizes()
        Clear custom sizes adjusted by user.
      • getModel

        public PivotModel getModel()
        Returns pivot model.
      • setModel

        public void setModel​(PivotModel model)
        Sets the pivot model.
      • setPivotRenderer

        public void setPivotRenderer​(PivotRenderer renderer)
        Sets the pivot renderer
      • getPivotRenderer

        public PivotRenderer getPivotRenderer()
        Returns the pivot renderer.
      • setAutowrap

        public void setAutowrap​(boolean autowrap)
        Sets whether auto wrap the content and adjust row height Note: It is strongly recommended NOT to use autowrap if there are huge amount of cells in one page or the performance at client side might be horrible.
        Parameters:
        autowrap -
      • isAutowrap

        public boolean isAutowrap()
        Gets whether auto wrap the content and adjust row height. Note: It is strongly recommended NOT to use autowrap if there are huge amount of cells in one page or the performance at client side might be horrible.
        Returns:
        boolean
      • isFrozenColumnHeaders

        public boolean isFrozenColumnHeaders()
        Returns:
        boolean
        Since:
        2.5.0
      • setFrozenColumnHeaders

        public void setFrozenColumnHeaders​(boolean frozenColumnHeaders)
        Enable frozen column headers. Useful in combination with a larger setPageSize(int) and fixed height/vflex.

        IE not supported. Potential causes performance issues with larger column or row sizes.

        Disabled by default.
        Parameters:
        frozenColumnHeaders -
        Since:
        2.5.0
      • onInitRender

        public void onInitRender​(org.zkoss.zk.ui.event.Event event)
        Only internal use to prepare the rendering information from the pivot model.
      • getZclass

        public String getZclass()
        Overrides:
        getZclass in class org.zkoss.zk.ui.HtmlBasedComponent
      • renderProperties

        protected void renderProperties​(org.zkoss.zk.ui.sys.ContentRenderer renderer)
                                 throws IOException
        Overrides:
        renderProperties in class org.zkoss.zul.impl.XulElement
        Throws:
        IOException
      • clone

        public Object clone()
        Specified by:
        clone in interface org.zkoss.zk.ui.Component
        Overrides:
        clone in class org.zkoss.zul.impl.XulElement
      • sessionWillPassivate

        public void sessionWillPassivate​(org.zkoss.zk.ui.Page page)
        Specified by:
        sessionWillPassivate in interface org.zkoss.zk.ui.sys.ComponentCtrl
        Overrides:
        sessionWillPassivate in class org.zkoss.zk.ui.AbstractComponent
      • sessionDidActivate

        public void sessionDidActivate​(org.zkoss.zk.ui.Page page)
        Specified by:
        sessionDidActivate in interface org.zkoss.zk.ui.sys.ComponentCtrl
        Overrides:
        sessionDidActivate in class org.zkoss.zk.ui.AbstractComponent
      • isChildable

        public boolean isChildable()
        Overrides:
        isChildable in class org.zkoss.zk.ui.AbstractComponent
      • service

        public void service​(org.zkoss.zk.au.AuRequest request,
                            boolean everError)
        Specified by:
        service in interface org.zkoss.zk.ui.sys.ComponentCtrl
        Overrides:
        service in class org.zkoss.zk.ui.HtmlBasedComponent
      • invalidate

        public void invalidate()
        Invalidates the pivottable, causing it to rerender. This method should be called after using Java API to manipulate the model associated with this pivottable. Otherwise, the view will not be updated. e.g. node.setOpen(true); pivottable.invalidate();
        Specified by:
        invalidate in interface org.zkoss.zk.ui.Component
        Overrides:
        invalidate in class org.zkoss.zk.ui.AbstractComponent
        Since:
        2.0.2