-
Notifications
You must be signed in to change notification settings - Fork 42
Dinamically create and destroy controls in ajax calls
IWBS controls can be dynamically created in ajax calls, after being created, controls are automatically rendered in active page as in regular vcl applications.
For example you can design a complete TIWFrame and you can add to current form at runtime with following code:
procedure TIWForm2.IWBSButton26AsyncClick(Sender: TObject; EventParams: TStringList);
var
cmp: TIWFrame1;
begin
cmp := TIWFrame1.Create(Self);
cmp.Name := IWBSGetUniqueComponentName(Self,'frame');
cmp.Parent := IWBSRegion17;
end;
If for any reason you need to refresh a control in ajax call, you can manually do with the AsyncRefreshControl procedure.
For example, if you are creating several components at one time you will get better performance if you force an AsyncRefreshControl on the parent region of that components so they will be rendered all in a single step.
For remove components in ajax calls you have two options:
- Before destroy component, execute AsyncRemoveControl procedure on that control.
- Force an AsyncRefreshControl on the parent container of that component.
IWBSModal region has also a property to auto destroy and remove component from DOM when you close it:
IWBSModal.DestroyOnHide := True;