CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

How to update the position of the ProgressBar

General discussion

by sakata » 17 May 2014 05:08

Hi.

How to update the position of the TIWCGJQProgressBar
in IWCGJQFileUpload.JQFileUploadOptions.onComplete Event ?

Code: Select all
procedure TFrom.IWCGJQFileUploadJQFileUploadOptionsComplete(Sender: TObject; AParams: TStringList);
begin
  if IWCGJQFileUpload.FileNames.Count = fStoredCount then begin
    IWCGJQProgressBar1.JQProgressBarOptions.Max := 4;
    IWCGJQProgressBar1.JQProgressBarOptions.Value := 1;
    {IWCGJQProgressBar1.AjaxReRender(false,true);} //->ProgressBar position refresh
    FuncStep1();
    IWCGJQProgressBar1.JQProgressBarOptions.Value := 2;
    FuncStep2();
    IWCGJQProgressBar1.JQProgressBarOptions.Value := 3;
    FuncStep3();
    IWCGJQProgressBar1.JQProgressBarOptions.Value := 4;
  end;
end;


Best regards
sakata
 
Posts: 5
Joined: 28 Apr 2014 06:43

by Jorge Sousa » 17 May 2014 15:42

Hello

First you've realize whats going on:

1- Browser calls the server, with the ajax request OnComplete.

2- TFrom.IWCGJQFileUploadJQFileUploadOptionsComplete is called in the server.

In this event, when change property values, like

IWCGJQProgressBar1.JQProgressBarOptions.Max := 4;
IWCGJQProgressBar1.JQProgressBarOptions.Value := 2;

The system generates javascript to be executed when the request backs to browser, all at once.
This is not a process where server calls browser, that's impossible.

So when the ajax request returns browser, there will be a set of javascript statements to be executed.

something like

$("#IWCGJQPROGRESSBAR1").progress("option","max",4);
$("#IWCGJQPROGRESSBAR1").progress("option","value",2);

So, without knowing what your FuncStepX functions do, at the end, the progress bar value will be 4: IWCGJQProgressBar1.JQProgressBarOptions.Value := 4;

or

$("#IWCGJQPROGRESSBAR1").progress("option","value",4);

If you could tells you what you try to achieve, maybe we could give you a proper solution, for client - server technology.
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by sakata » 22 May 2014 07:25

Hello

>$("#IWCGJQPROGRESSBAR1").progress("option","value",4);

I do not know how the server callback

So, I solved the problem by using the TIWTimer
Code: Select all
procedure TFrom.IWCGJQFileUploadJQFileUploadOptionsComplete(Sender: TObject; AParams: TStringList);
begin
  if IWCGJQFileUpload.FileNames.Count = fStoredCount then begin
    IWTimer1.Tag := 1;
    IWTimer1.Enabled  := true;
  end;
end;

procedure TFrom.IWTimer1AsyncTimer(Sender: TObject; EventParams: TStringList);
begin
  inherited;
  IWTimer1.Enabled := false;
  case IWTimer1.Tag of
    1: begin
      IWCGJQProgressBar1.JQProgressBarOptions.Max := 4;
      IWCGJQProgressBar1.JQProgressBarOptions.Value := 1;
      IWTimer1.Tag := 2;
    end;
    2: begin
      FuncStep1();
      IWCGJQProgressBar1.JQProgressBarOptions.Value := 2;
      IWTimer1.Tag := 3;
    end;
    3: begin
      FuncStep2();
      IWCGJQProgressBar1.JQProgressBarOptions.Value := 3;
      IWTimer1.Tag := 4;
    end;
    4: begin
      FuncStep3();
      IWTimer1.Tag := 99;
    end;
    99: begin
      if IWCGJQProgressBar1.JQProgressBarOptions.Value <> IWCGJQProgressBar1.JQProgressBarOptions.Max then begin
        IWCGJQProgressBar1.JQProgressBarOptions.Value := IWCGJQProgressBar1.JQProgressBarOptions.Max;
        IWCGMessageDlg('Upload is success',mtInformation,[mbOK],
        procedure(Dialog: TIWCGJQMsgDialog; AResult: TModalResult)
        begin
          IWTimer1.Tag := 0;
        end);
      end;
    end;
  end;
  IWTimer1.Enabled := IWTimer1.Tag <> 0;
end;
sakata
 
Posts: 5
Joined: 28 Apr 2014 06:43

by Jorge Sousa » 22 May 2014 09:39

Hi

I think you found the right solution now
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58


Return to General - Archive

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.