CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> General/Other

 How to use Validation Rule in Editable Grid

Print topic Send  topic

Author Message
Ozum

Posts: 57
Posted: 11/25/2004, 7:22 AM

Hello,

You can answer the quiestion in any language you want, but in case you need, I use Perl 5.8 on PostgreSQL 7.4 at Apache 2.

I need to check a control's value according to another control's value in editable grid with validation rule in CCS (i.e data panel in properites tab).

For example I have two textboxes, and I want user only fills one of them using validation rule. How can I refer to value of other textbox. I can't use $form->{'control_name'}->GetValue, because it can not be used at validation rule. I can't use CCGetParam('parameter',0), because it is editable grid and there is lots of controls with same name differs by number.

I know there are another ways to do this task, but this task is just for example, the point is I want to know how to use validation rule.

Regards,
Ozum
View profile  Send private message
mrachow


Posts: 509
Posted: 11/25/2004, 10:42 AM

Why do you think the value of a control cannot ben used/retrieved in validation event?

Thats just the main purpose of that event to check the entered values.

Kindly regards,
Michael
_________________
Best regards,
Michael
View profile  Send private message
Ozum

Posts: 57
Posted: 11/26/2004, 3:24 AM

Hello Michael,

I totally agree with you, in fact in Record Forms it is true, but in case of Editable Grid, when I call

$record->{'control'}->GetValue

the following error occurs:

Can't call method "GetValue" on an undefined value

Regards,
Ozum
View profile  Send private message
Ozum

Posts: 57
Posted: 11/26/2004, 3:27 AM

Sorry for misspelling your nickname mrachow :-O My eyes gets worse, living face to face with my computer monitor :-/
View profile  Send private message
mrachow


Posts: 509
Posted: 11/26/2004, 5:32 AM

Only to be quite sure.
Is your grid form named record?

Thanks,
Michael
_________________
Best regards,
Michael
View profile  Send private message
Ozum

Posts: 57
Posted: 11/26/2004, 5:46 AM

Hello,

My grid form is named through CCS Interface. It's name is 'page_grant',
the controls are named, 'grant_view', 'grant_update', 'grant_delete' and 'grant_create'.

To acces value I use

$page_grant->{'grant_update'}->GetValue;

This is usual access method to a control's value in a record form.

In my opinion since 'validation rule' check occurs after submit, these values are undefined.

You can see it what I mean by creating an editable grid, and try to use one of the control's 'validation rule' attribute in CCS Interface, and try to access a control's value.

If you can access the value and share the way with me I'll be very happy. By the way it doesn't have to be Perl, I can try to understand other languages too.

Thanks,
Ozum
View profile  Send private message
mrachow


Posts: 509
Posted: 11/26/2004, 5:49 AM

What type of control is it you are trying to retrieve the value?
Label or text box?

Thanks,
Michael
_________________
Best regards,
Michael
View profile  Send private message
Ozum

Posts: 57
Posted: 11/26/2004, 5:54 AM

The four controls are ( grant_update etc ) listbox and there is one textbox ('grant_name')

Thanks,
Ozum
View profile  Send private message
mrachow


Posts: 509
Posted: 11/26/2004, 6:32 AM

What I have done to check

In OnValidate event of form as well as of control I had added
- action declare variable
- action save controls value to that variable
- custom code where I have used the variable value as error string.

In case of of control event it has generated an "error" for every line and in case of form event one error with the value of the control of the last line of the grid.

I have an AS project handy and it looks like
'Declare Variable @98-6AE7A4E9
Dim mics
'End Declare Variable

'Save Control Value @96-AA0E35B2
mics = today.ListBox1.Value
'End Save Control Value

'Custom Code @99-73254650
' -------------------------
' Write your own code here.
' -------------------------
today.Errors.addError("1: " & mics & "<br>")
'End Custom Code

The first two parts were generated by Studio due to the defined actions.

The control is a listbox in a table cell of an editable grid.

Regards,
Michael
_________________
Best regards,
Michael
View profile  Send private message
Ozum

Posts: 57
Posted: 11/26/2004, 6:47 AM

Thank you Michael,

At this time, like you, I use Server Action Events too. There is no problem with that.

But I wonder how to use the 'Validation Rule' at the Properties Window at 'Data' Tab with editable grid. It is the window where you define control's name, caption, control source etc. 'Validation Rule' is at the bottom of that panel over 'Validation Text' property.

This property makes a quick check and if it is not satidfied it prints whatever you write in 'Validation Text'.

I use these properties in record forms to quickly validate the values and print the error if necessary.

Just for example:

In Validation Rule I wirte a xor (not or)

  
$page_grant->{'grant_update'}->GetValue xor $page_grant->{'grant_view'}->GetValue  

In Validation Text I write
  
You can not fill update and view actions at the same time.  

This works well in record forms, but I can't do this for editable grid forms.

Thanks,
Ozum
View profile  Send private message
mrachow


Posts: 509
Posted: 11/26/2004, 1:00 PM

Ahh, now I got it.

Sorry I havn't read your posts not carefully enough.

If you are using any one of the predefined actions not any item you are entering into the property fields, should depend on the target language.

All what will be necessary to make these actions work should be generated by Studio for the target language you have chosen.

So for example if you have to enter a control for some property it should be enough to enter its name. There should be no (language dependend) reference chain like $form->controlName or form.controlName.
If you are forced to enter something like this there (and it would even work) it's an issue for support to mark it as a bug.

In opposite to custom code the predefined actions are indended to be language independent.

Kindly regards,
Michael
_________________
Best regards,
Michael
View profile  Send private message
Ozum

Posts: 57
Posted: 11/26/2004, 9:31 PM

Yes, predefined actions are language independent, but this not an action. This is a property of a control. In CCS Help it is described as follows:

Validation Rule Property

Description:
This property presents you with the opportunity to enter a programming language specific condition that will be used to determine the validity of the submitted value. If the requirement is not satisfied the error message from Validation Text property is shown.

Example:
For instance, if using ASP and you have a control that submits date values, you can enter a simple condition to ensure that the date is later than the current date i.e. FieldName is the name of the control being validated.
FieldName.Value > Date()

You can see it searching the term 'Validation Rule Property' in CCS Help.

Thanks,
Ozum
View profile  Send private message
peterr


Posts: 5971
Posted: 11/27/2004, 3:45 PM

I believe that the validation in Editable Grids is done at control's level rather than form level, therefore you can only refer to the current control. I also believe that in certain languages you can refer to controls that were executed earlier but not later.
I may be wrong - this is just what I remember from earlier discussions on this forum.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.