Question

I have an application in Delphi 7 which is using a clientdataset, and make several operations on it. ClientDataSet is linked to an Intraweb Grid.

I make an insert or an edit on the ClientDataSet. How can I verify the data introduced in the clientdataset for each field? I can not verify the input from the user on the webform, so I must make validation using ClientDataSet events.

LE: I want to validate data when the user make the input. Not at the onbeforepost event. So, I put the clientdataset in the edit/insert. User make an input in the grid, and I want to validate the data for that row in the clientdataset like in the image bellow:

enter image description here

first column is string, second is integer, the third one is also an integer. Now, I want to validate the third column after the user make the input. This validation must be done (if it is possible), only by using clientdataset events/hacks.

Was it helpful?

Solution

You should handle TClientDataset BeforePost event, and if data is not valid use abort method

OTHER TIPS

TField has an OnValidate event for that purpose. It has also a CustomConstrain property that can use a SQL like syntax for constraints. DefaultExpression will let you select a value if no value is given. These are usuful for single-field validation. If you need more complex checks across more than one field, then you have to use dataset or datasource events.

Anyway, if the Intraweb grid sends the server whole records and not single fields edits, you may not validate fields as they are entered in the grid but adding code client side.

If you want a field based validation, you can handle the OnDataChange event of the TDatasource connecting the grid to the dataset. This will be triggered whenever a field has been changed by the user. You should be aware that it will also be triggered in some other situations.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top