Class WidgetRenderer<T,​W extends com.google.gwt.user.client.ui.Widget>

  • Type Parameters:
    T - the row data type
    W - the Widget type
    All Implemented Interfaces:
    Renderer<T>
    Direct Known Subclasses:
    ClickableRenderer, ProgressBarRenderer

    public abstract class WidgetRenderer<T,​W extends com.google.gwt.user.client.ui.Widget>
    extends ComplexRenderer<T>
    A renderer for rendering widgets into cells.
    Since:
    7.4
    Author:
    Vaadin Ltd
    • Constructor Detail

      • WidgetRenderer

        public WidgetRenderer()
    • Method Detail

      • init

        public void init​(RendererCellReference cell)
        Description copied from class: ComplexRenderer
        Called at initialization stage. Perform any initialization here e.g. attach handlers, attach widgets etc.
        Specified by:
        init in class ComplexRenderer<T>
        Parameters:
        cell - The cell. Note that the cell is not to be stored outside of the method as the cell instance will change. See FlyweightCell
      • createWidget

        public abstract W createWidget()
        Creates a widget to attach to a cell. The widgets will be attached to the cell after the cell element has been attached to DOM.
        Returns:
        widget to attach to a cell. All returned instances should be new widget instances without a parent.
      • render

        public void render​(RendererCellReference cell,
                           T data)
        Description copied from interface: Renderer
        Called whenever the Grid updates a cell.

        For optimal performance, work done in this method should be kept to a minimum since it will be called continuously while the user is scrolling. It is recommended to set up the cell's DOM structure in ComplexRenderer.init(RendererCellReference) and only make incremental updates based on cell data in this method.

        Parameters:
        cell - The cell. Note that the cell is a flyweight and should not be stored outside of the method as it will change.
        data - The column data object
      • render

        public abstract void render​(RendererCellReference cell,
                                    T data,
                                    W widget)
        Renders a cell with a widget. This provides a way to update any information in the widget that is cell specific. Do not detach the Widget here, it will be done automatically by the Grid when the widget is no longer needed.

        For optimal performance, work done in this method should be kept to a minimum since it will be called continuously while the user is scrolling. The renderer can use Widget.setLayoutData(Object) to store cell data that might be needed in e.g. event listeners.

        Parameters:
        cell - The cell to render. Note that the cell is a flyweight and should not be stored and used outside of this method as its contents will change.
        data - the data of the cell
        widget - the widget embedded in the cell
      • getWidget

        protected W getWidget​(com.google.gwt.dom.client.TableCellElement e)
        Returns the widget contained inside the given cell element. Cannot be called for cells that do not contain a widget.
        Parameters:
        e - the element inside which to find a widget
        Returns:
        the widget inside the element
      • getWidget

        protected static <W extends com.google.gwt.user.client.ui.Widget> W getWidget​(com.google.gwt.dom.client.TableCellElement e,
                                                                                      Class<W> klass)
        Returns the widget contained inside the given cell element, or null if it is not an instance of the given class. Cannot be called for cells that do not contain a widget.
        Parameters:
        e - the element inside to find a widget
        klass - the type of the widget to find
        Returns:
        the widget inside the element, or null if its type does not match