Jump to content

GRID - Disable Row Editing Based on Cell Value


bruno-pere

Recommended Posts

Hi!

 

I want to enable/disable row editing in a grid based on a value of a cell (linked to a dataset).

 

I tried beforeedit event but without success.

 

Thx!

 

Bruno

 

BeforeEdit Even will work, try

 

procedure TForm1.QryMainBeforeEdit(DataSet: TDataSet)

begin

if QryMainColor.AsString<>'Green' then Abort;

end;

Link to comment
Share on other sites

Thx! Sometimes we forget to use the easy way! I was trying with ajax.

 

It worked now, but required a change.

 

The grid immediately posts the changes or abort the operation based on a column value.

 

 

 

In Grid.ExtEvents->ValidateEdit

 

function OnValidateedit(e)

{

ajaxRequest(UniFrameTransf.GridTransf,

'ValidateEdit',

['val='+e.value]);

}

 

 

 

In the Grid.OnAjaxEvent

 

procedure TUniFrameTransf.GridTransfAjaxEvent(Sender: TComponent; EventName: string;

Params: TStrings);

begin

if EventName='ValidateEdit' then

begin

AbortEdit := AdoQueryTransf.FieldByName('OPERACAO').AsString='R';

 

if not AbortEdit then

begin

if not (AdoQueryTransf.State in ([dsEdit, dsInsert])) then

AdoQueryTransf.Edit;

AdoQueryTransfQUANTIDADE.Value := Params.Values['val'];

AdoQueryTransf.Post;

end;

end

end;

 

 

 

In TADOQuery.OnBeforeEdit

 

procedure TUniFrameTransf.ADOQueryTransfBeforeEdit(DataSet: TDataSet);

begin

if AbortEdit then

Abort;

end;

 

 

 

Declare AbortEdit as boolean in private.

 

 

Thx!

 

Bruno

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...