EhLib.Com
https://forum.ehlib.com/en/

TmemtableEh loa dataset in runtime.
https://forum.ehlib.com/en/viewtopic.php?f=5&t=1108
Page 1 of 1

Author:  Proyectoanamnesis [ 05 Oct 2021, 21:50 ]
Post subject:  TmemtableEh loa dataset in runtime.

Hello.
The control "Tmemtableeh" have a method clonecursor or copyDatset or similar ?

I need load/ fill this component with a query that I'have in runtime.

Author:  EhLibSupport [ 05 Oct 2021, 23:33 ]
Post subject:  Re: TmemtableEh loa dataset in runtime.

Hello

There is a method - LoadFromDataSet

Code:
function TCustomMemTableEh.LoadFromDataSet(Source: TDataSet; RecordCount: Integer;
  Mode: TLoadMode; UseCachedUpdates: Boolean): Integer;


Loads not more then RecordCount records from Source DataSet to itself. If RecordCount = -1 then it load all record. If Mode parameter is lmCopy then all data will be deleted before loading. If Mode parameter is lmAppend then new records will be added to existing data.
UseIfCachedUpdates parameter define that new records gets usInserted status.

Author:  souarit [ 01 Aug 2022, 10:12 ]
Post subject:  Re: TmemtableEh loa dataset in runtime.

is there any idea to load (copy) only selected rows in a DbgridEh to another TMemtableEh ?

Author:  EhLibSupport [ 02 Aug 2022, 04:50 ]
Post subject:  Re: TmemtableEh loa dataset in runtime.

Hello

Here is the code that creates a structure in a new MemTable and copies only selected in the grid records.

Code:
procedure TForm1.CopySelectedRecords(SrcGrid: TDBGridEh;
  TargetMemTable: TMemTableEh);
var
  SrcMemTable: TMemTableEh;
  I: Integer;
begin
  SrcMemTable := SrcGrid.DataSource.DataSet as TMemTableEh;
  TargetMemTable.CopyStructure(SrcMemTable);

  TargetMemTable.CreateDataSet;

  SrcMemTable.DisableControls;
  for I := 0 to SrcGrid.SelectedRows.Count - 1 do
  begin
    SrcMemTable.GotoBookmark(SrcGrid.SelectedRows[i]);
    TargetMemTable.LoadFromMemTableEh(SrcMemTable, 1, lmAppend, []);
  end;

  SrcMemTable.EnableControls;
end;

Author:  souarit [ 02 Aug 2022, 07:16 ]
Post subject:  Re: TmemtableEh loa dataset in runtime.

EhLibSupport wrote:
Hello

Here is the code that creates a structure in a new MemTable and copies only selected in the grid records.

Code:
procedure TForm1.CopySelectedRecords(SrcGrid: TDBGridEh;
  TargetMemTable: TMemTableEh);
var
  SrcMemTable: TMemTableEh;
  I: Integer;
begin
  SrcMemTable := SrcGrid.DataSource.DataSet as TMemTableEh;
  TargetMemTable.CopyStructure(SrcMemTable);

  TargetMemTable.CreateDataSet;

  SrcMemTable.DisableControls;
  for I := 0 to SrcGrid.SelectedRows.Count - 1 do
  begin
    SrcMemTable.GotoBookmark(SrcGrid.SelectedRows[i]);
    TargetMemTable.LoadFromMemTableEh(SrcMemTable, 1, lmAppend, []);
  end;

  SrcMemTable.EnableControls;
end;


perfect ! thank you very much.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/