bruno-pere Posted December 20, 2012 Posted December 20, 2012 Hi! I am trying to post the grid record immediately to the database after a cell has been edited. Actually, the record is posted to the database only after a scroll. I've been playing with ExtEvents of the grid like OnAfterEdit, OnValidateEdit and some procedures of the ExtJs store like commitChanges() and save() but without success. Does anyone know how to do that? Thx! Bruno Quote
Mediv Posted December 21, 2012 Posted December 21, 2012 The same question arises when editing data grid, made with Timer. Perhaps this is what you need. procedure DataVirtualTableAfterEdit(DataSet: TDataSet); begin inherited; UniTimer.Enabled := True; end; // procedure UniTimerTimer(Sender: TObject); begin inherited; UniTimer.Enabled := False; // DataVirtualTable.DisableControls; ... DataVirtualTable.edit; ... DataVirtualTable.post; ... DataVirtualTable.Next; // DataVirtualTable.EnableControls; end; Quote
bruno-pere Posted December 21, 2012 Author Posted December 21, 2012 Worked here... but i appreciate a better solution... In the Grid ExtEvents -> OnValidateEdit function OnValidateedit(e) { ajaxRequest(UniFrameCons.GridCons, 'ValidateEdit', ['val='+e.value]); } In the Grid OnAjaxEvent procedure TUniFrameCons.GridConsAjaxEvent(Sender: TComponent; EventName: string; Params: TStrings); begin if EventName='ValidateEdit' then begin if not (AdoQueryCons.State in ([dsEdit, dsInsert])) then AdoQueryCons.Edit; AdoQueryConsQUANTIDADE.Value := Params.Values['val']; AdoQueryCons.Post; end; end; ATTENTION: This code works for me because ONLY one column can be edited in this grid. If you have more columns to be edited you should change this code. Bye! Bruno Quote
bruno-pere Posted February 13, 2013 Author Posted February 13, 2013 Updating... To know what column sent the ValidateEdit and post immediately... Declare type THackGrid = class(TUniDBGrid); And in the grid ajaxevent procedure TUniFramePed.gridIPAjaxEvent(Sender: TComponent; EventName: string; Params: TStrings);var col: integer;begin if EventName='ValidateEdit' then begin col := THackGrid(GridIP).CurrCol; if (col=8)or(col=9) then begin if not (AdoQueryIP.State in ([dsEdit, dsInsert])) then AdoQueryIP.Edit; if col=8 then // caixa AdoQueryIPQUANTIDADE_CX.Value := Params.Values['val'] else if col=9 then // kg AdoQueryIPQUANTIDADE.Value := Params.Values['val']; AdoQueryIP.Post; end; end;end; OnValidateEdit in ExtEvents remains the same, but attention to uppercase or lowercase in the grid name. JavaS will recognize only the exact name of the component in the form. Like: function OnValidateedit(e){ ajaxRequest(UniFramePed.gridIP, 'ValidateEdit', ['val='+e.value]);} 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.