TTIWDBAdvWebGrid and LookUp Fields

Hi.

This is my current scenario:
2 TADOQuery
1 TDataSource
1 Look field
4 TTIWAdvToolButton calling Insert, Edit, Post and Cancel from the TADOQuery
1 TTIWDBAdvWebGrid

The DBAdvWebGrid have one column with the DataField property to the Lookup Field and the Editor property set to edCombo.

When
I press the Insert button the DBAdvWebGrid show the record with a field
value in the column and the editor (edCombo) as well, if I click on the
Post button as the value from the lookup field is not select manually I
get the exception from the Database.

For overcoming this
situation in the BeforePost event I validate the value and cancel the
Insert/Edit mode. I just want to give a message to the user telling him
that the value from the column need to be selected and continue in the
edit mode.

Another thing that I tried is to call the Abort method
inside the BeforePost but I get the exception "Uninitialized reply" and
the program stop working and show nothing on the form.

I use:
Delphi Berlin Update 2
Intraweb 14.1.14
TMS 5.8.8.0

Hi,


Have you tried using the OnPostValidate event of the TTIWDBAdvWebGrid?

Hi.

I've try what you said (before posting here), but this method only triggers if the Grid has a Column with ColumnType ctDataButton.

Do you really try my scenenario???

When you programmatically call grid.Post; , the OnPostValidate event will be triggered.

Hi!


Bruno, thank you for the answers.

It's looks like I don't make myself clear, I will try to explain myself more clear.

I have several TTIWAdvToolButton in a TFrame in all my form of my project (300 - 400 forms)
calling Insert, Edit, Post, Cancel and Delete from a TADOQuery. This I can not change.

Example:

procedure TFrame.btnInsertClick(Sender: TObject);
begin
   TADOQuery.Insert;
end;

procedure TFrame.btnEditClick(Sender: TObject);
begin
   TADOQuery.Edit;
end;

procedure TFrame.btnPostClick(Sender: TObject);
begin
   TADOQuery.Post;
end;

procedure TFrame.btnCancelClick(Sender: TObject);
begin
   TADOQuery.Cancel;
end;

procedure TFrame.btnDeleteClick(Sender: TObject);
begin
   TADOQuery.Delete;
end;

In several forms I have a DBAdvWebGrid, some of them I have one column with the DataField property to a Lookup Field and the Editor property set to edCombo.

When the user does Click on the btnInsert (TFrame), the column show a value, the user assume that the value is selected and does Click on the btnPost (TFrame). Doing this if the column is not null in the database the app raise a exception or if the column has a foreign key does another king of exception.

I want to validate or that the field take the value shown when the user does click on the btnInsert.

Is possible to have a solution to my specific scenario???

Sorry, for the grid  to  be able to  process the OnPostValidate at the right time, i.e. before the actual post at dataset level will happen, it is required to call grid.Post