Jump to content

Recommended Posts

Posted

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

Posted

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;

Posted

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

  • 1 month later...
Posted

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]);
}

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...