Runtime Life Cycle of Custom Control Used within Grid Pane

Using a custom control within a grid pane uses a specialized life cycle. It depends on the supported Render Modes of the Control Type and the Always Render setting on the Control.

If a grid pane is not in the Always Render mode, only one instance of the ControlWrapper gets created for a column. Each cell in that column shares that single instance. When the runtime invokes methods, such as refresh() and getFormattedValue() on the wrapper, the getControl() method on the component interface returns the specific instance for that cell. This way, the ControlWrapper implementation gets specific configuration details of that cell.

Preparation

The forms runtime repeatedly calls the ControlWrapper's isReady() method until it returns true.

Initialization

When you configure the control in the Always Render mode, the form creates an instance of the ControlWrapper for each cell in the grid table. Users can view the rendering that happens at this point.

When you do not configure the control in the Always Render mode (default), the form creates a single ControlWrapper instance that is shared between the cells in a grid table column. Users cannot view the rendering that happens at this point. The form does not attach the parent node to the DOM at this point but invokes the ControlWrapper.getFormattedValue() method for each visible cell in the column of the grid table.

Refresh

When you configure the control in the Always Render mode, the form calls the refresh() method as soon as the value or other configuration settings are changed.

When you do not configure the control in the Always Render mode and focus on a cell to edit the value, the form calls the ControlWrapper.refresh() method to allow the ControlWrapper to update the rendering and reflect the current value being edited. If you change any of the configuration settings after the last refresh(), the wrapper is notified through the updates argument.

Sorting

If a control manages a complex value, the static compare() method on the ControlWrapper class is called each time user sorts the grid on that column.

Destruction

When you configure the control in Always Render mode, the form invokes the destroy() method on all instances of the ControlWrapper when the form is being taken out of service or on the specific instance when that row is deleted from the table.

If you do not configure the control in the Always Render mode, the form invokes the destroy() method on the shared instance of the ControlWrapper only when the form is being taken out of service.