Page 1 of 1

Validation from DB Nav button

PostPosted: 27 Aug 2014 03:05
by mjq
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?

Re: Validation from DB Nav button

PostPosted: 27 Aug 2014 10:05
by Alexander Bulei
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.

Re: Validation from DB Nav button

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

Re: Validation from DB Nav button

PostPosted: 18 Sep 2014 09:14
by mjq
The test program now uploaded.
(requires sqlite3.dll)
The point of the problem is l.214 of UStartFrame unit...

Re: Validation from DB Nav button

PostPosted: 18 Sep 2014 10:29
by Jorge Sousa
Hi

Register under Internal ticket nr SRC00040453

Re: Validation from DB Nav button

PostPosted: 23 Sep 2014 09:51
by Jorge Sousa
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;