bruno-pere Posted December 26, 2012 Posted December 26, 2012 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 Quote
Ronak Posted December 26, 2012 Posted December 26, 2012 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; Quote
bruno-pere Posted December 26, 2012 Author Posted December 26, 2012 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.