CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Dialog.Button.Clear not working

by eosventas » 11 Feb 2015 22:15

I have a Dialog, in some parts of my program I need it with TWO buttons, and everything is ok

But in some other parts I use the same dialog and use JQOptions.Button.Clear but it does not work, it keeps showing the same two buttons I already define.

I am using CGDevTools V2.5.0.17 beta for IW14.0.36

Because of my bad english I include a sample code to show what I mean :(

How can I really make those buttons away when I don't need them anymore
You do not have the required permissions to view the files attached to this post.
eosventas
 
Posts: 7
Joined: 01 Feb 2015 09:55

by Alexander Bulei » 12 Feb 2015 11:41

Hi eosventas,

This happens because you need re-render the dialog.

TCollection's (JQDialogOptions.Buttons) doesn't supports ajax change, so you need call AjaxReRender method.

Almost all properties in JQ<component_name>Options supports changing in asynchronous.

Other thing, you don't need define the AutoOpen property, dialog uses it only on page render.

In your case you need put the AjaxReRender on both procedures:

delphi code
procedure TIWForm1.IWCGJQButton1JQButtonOptionsClick(Sender: TObject;
AParams: TStringList);
var iButtom: TIWCGJQCustomDialogButton;
begin
IWCGJQLabel1.Caption := 'This Dialog has TWO buttons';

with IWCGJQDialog1 do
begin
//JQDialogOptions.AutoOpen:= True; // USELESS IN THIS CASE
JQDialogOptions.Buttons.Clear;
JQDialogOptions.Title:= 'Any Title';
JQDialogOptions.Modal:= True;
Visible:= True;

iButtom:= JQDialogOptions.Buttons.Add;
iButtom.Text:= 'first choice';

iButtom:= JQDialogOptions.Buttons.Add;
iButtom.Text:= 'second choice';

// RE-RENDER THE DIALOG
AjaxReRender(True,False);
end;
end;

procedure TIWForm1.IWCGJQButton2JQButtonOptionsClick(Sender: TObject;
AParams: TStringList);
begin
IWCGJQLabel1.Caption := 'This Dialog should has NO buttons at all because we use JQDialogOptions.Buttons.Clear';

with IWCGJQDialog1 do
begin
//JQDialogOptions.AutoOpen:= True; // USELESS IN THIS CASE
JQDialogOptions.Buttons.Clear; //HERE WE CLEAR THE BUTTONS
JQDialogOptions.Title:= 'Any Title';
JQDialogOptions.Modal:= True;
Visible:= True;

// RE-RENDER THE DIALOG
AjaxReRender(True,False);
end;
end;


Best Regards.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by eosventas » 12 Feb 2015 17:11

Thank you so much =)
eosventas
 
Posts: 7
Joined: 01 Feb 2015 09:55

by eosventas » 14 Feb 2015 22:06

Additional tip for programmers using the recommendation posted here..........

In certain situations I was having the following error

Error message: Method "RenderRegionAsync" it's only allowed in Ajax Processing!


That is fixed with :

delphi code
uses IWCGJQCommon;

// RE-RENDER THE DIALOG
if CGIsCallBackProcessing then
AjaxReRender(True,False);
eosventas
 
Posts: 7
Joined: 01 Feb 2015 09:55


Return to JQDialogEx

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.