Skip to main content

TcxCustomPivotGrid.OnInitStoredObject Event

Enables you to initialize fields that are created when restoring the pivot grid’s layout from external data stores.

Declaration

property OnInitStoredObject: TcxInitStoredObjectEvent read; write;

Remarks

When the pivot grid’s layout is restored from a data store by calling the RestoreFromIniFile, RestoreFromRegistry, or RestoreFromStream method, and a data store field is missing in the grid control, this field is automatically created in the pivot grid, provided that the method is called with True passed as the ACreateChildren parameter. After it’s been created, the OnInitStoredObject event is fired. You can handle this event to properly initialize the object which corresponds to the created field. Initialization includes re-associating field events with existing event handlers and assigning field properties.

The pivot grid being restored from a data store and the field that has been created are passed as the Sender and AObject parameters of the OnInitStoredObject event, respectively.

The following code represents the OnInitStoredObject event handler, demonstrating how to re-associate the events of all the fields (no specific identification is made) whose property storing and restoring is customized by handling a field’s OnGetStoredProperties, OnGetStoredPropertyValue and OnSetStoredPropertyValue events with existing event handlers (the FieldGetStoredProperties, FieldGetStoredPropertyValue and FieldSetStoredPropertyValue procedures, respectively).

procedure <Form>.<PivotGrid>InitStoredObject(Sender, AObject: TObject);
begin
  if AObject is TcxPivotGridField then
    with TcxPivotGridField(AObject) do
    begin
      OnGetStoredProperties := FieldGetStoredProperties;
      OnGetStoredPropertyValue := FieldGetStoredPropertyValue;
      OnSetStoredPropertyValue := FieldSetStoredPropertyValue;
    end;
end;
See Also