CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Validation from DB Nav button

by mjq » 27 Aug 2014 03:05

Hello!

I assigned OnClick.OnEvent of 'Post' button, and implemented the handler as following:

delphi code
//Post button
procedure TJQFrame1.IWCGJQNavigator1JQButtonSetOptionsButtons10Click(
Sender: TObject; AParams: TStringList);
begin
if DoValidate then begin
Query1.Post;
IWCGJQGrid1.JQGridOptions.ReloadGrid(True);
end
else
Exit;
end;

//private func.
function TJQFrame1.DoValidate: Boolean;
begin
JQEdtStoreCd.JQValidateOptions.Validate;
JQEdtStoreNm.JQValidateOptions.Validate;
JQEdtMaxCallCnt.JQValidateOptions.Validate;

Result := JQEdtStoreCd.JQValidateOptions.IsValid and
JQEdtStoreNm.JQValidateOptions.IsValid and
JQEdtMaxCallCnt.JQValidateOptions.IsValid;
end;


When Post button clicked, 'DoValidate' function returned 'True',
even if the text of the JQEdit violated the defined rules.

BTW, I tried to run 'DoValidate' function from JQButton.OnClick event handler,
then Validation executed properly(JQEdit was validated). :?

Is there anything wrong?
mjq
 
Posts: 58
Joined: 20 Aug 2014 02:46

by Alexander Bulei » 27 Aug 2014 10:05

Hi mjq,

We don't see the reason to have this behavior.

Can you make the simple testcase? t.i.a

P.S: If you don't need to show the error message on edit's, then you don't need call the validate method.

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 mjq » 18 Sep 2014 08:42

The result which I investigated is...

If the layout is simple (one JQFrame on one MainForm), it worked well,
but when the layout is complex like the demo app (JQueryDemoIW14_V2)
and this app has the side menu which changes frame,
same procedure behaved different.

To tell the truth, my app's layout is latter and
has some strange behaviors,
like initial size of grid, like default row count of the grid, and so on.

What should I do... :oops:
mjq
 
Posts: 58
Joined: 20 Aug 2014 02:46

by mjq » 18 Sep 2014 09:14

The test program now uploaded.
(requires sqlite3.dll)
The point of the problem is l.214 of UStartFrame unit...
You do not have the required permissions to view the files attached to this post.
mjq
 
Posts: 58
Joined: 20 Aug 2014 02:46

by Jorge Sousa » 18 Sep 2014 10:29

Hi

Register under Internal ticket nr SRC00040453
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by Jorge Sousa » 23 Sep 2014 09:51

Hello

I think your problem is resumed to this function;:

function TStartFrame.DoValidate: Boolean;
begin
JQEdtCode.JQValidateOptions.Validate;
JQEdtName.JQValidateOptions.Validate;

//
// this returns True even if there are some errors...
//
Result := JQEdtCode.JQValidateOptions.IsValid and
JQEdtName.JQValidateOptions.IsValid;
end;

That would be fine if .Validate reverted the Client+Server flow, and Server could call Client, which cannot.

For these cases you've to make sure the validation script is executed before calling your post button click server event :


Code: Select all
procedure TStartFrame.IWCGJQFrameCreate(Sender: TObject);
var
  InsScript: string;
  Script: string;
  p: Integer;
begin
  InsScript:= JQEdtCode.JQValidateOptions.jsValidate(False) +  JQEdtName.JQValidateOptions.jsValidate(False);

  Script:= IWCGJQNavigator1.Buttons.Post.OnClick.ScriptToExecute;
  p:= pos('{',Script);

  Insert(InsScript,Script,p+1);

  IWCGJQNavigator1.Buttons.Post.OnClick.Script:= Script;
end; 

Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58


Return to JQNavigator

cron

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.