Components for Delphi and C++ Builder.

Go to Russian forum
Go to EhLib.com
It is currently 28 Mar 2024, 14:48

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: 05 Oct 2021, 21:50 
Offline

Joined: 25 Jun 2021, 23:40
Posts: 3
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.


Top
 Profile  
 
PostPosted: 05 Oct 2021, 23:33 
Offline

Joined: 08 May 2014, 18:06
Posts: 660
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.

_________________
Best regards
EhLib Support Team


Top
 Profile  
 
PostPosted: 01 Aug 2022, 10:12 
Offline

Joined: 29 Oct 2013, 11:58
Posts: 13
is there any idea to load (copy) only selected rows in a DbgridEh to another TMemtableEh ?


Top
 Profile  
 
PostPosted: 02 Aug 2022, 04:50 
Offline

Joined: 08 May 2014, 18:06
Posts: 660
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;

_________________
Best regards
EhLib Support Team


Top
 Profile  
 
PostPosted: 02 Aug 2022, 07:16 
Offline

Joined: 29 Oct 2013, 11:58
Posts: 13
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 57 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group