Delete a row in the DBGrid without deleting in the Database

2

Would you like to delete one or more rows from a particular DBGrid without deleting the database record?

I was trying something like this but it did not work out.

while not DataModuleGeral2.qryAudienciasInicial.Eof do
begin
  if (DM.qryAudienciasDATA_AUDIENCIA.AsDateTime = Date) and
     (DM.qryAudienciasHORA_AUDIENCIA.AsDateTime < Time) then
  begin
     frmTelaPrincipal.dbgAudiencias.SelectedRows.Delete;
  end else
    DataModuleGeral2.qryAudienciasInicial.Next;
end;

I use Firebird 2.5 and Delphi

    
asked by anonymous 03.05.2018 / 21:40

2 answers

3

You can use the Filter field of the InitialStart to hide the records you do not want to show to the user

Something like

qryAudienciasInicial.Filter:='(ID<>5) AND (ID<>6)';
qryAudienciasInicial.Filtered:=true;

Of course here you should save the records that the user deletes to make this filter more dynamic.

    
03.05.2018 / 23:10
2

You can play the data in a TFDMemTable instead of working directly in the query, so you link the TFDMemTable in the DBGrid. To delete the records you want, just remove them from TFDMemTable and refresh the grid.

    
03.05.2018 / 21:54