Page 1 of 1
Iterate records by index in TVirtualTable
Posted: Fri 27 Jul 2018 03:04
by DmitryV
Hello, there is feature request :-)
Subj; for iterate records like this
for i := 0 to RecCount - 1 do
, without moving the internal cursor, approximately as in TMemTableEh (EhLib).
I mean it would be very useful, especially with the possibility of moving some records to another index position.
Can it be implemented in future versions? Somewhen
Re: Iterate records by index in TVirtualTable
Posted: Mon 30 Jul 2018 09:37
by MaximG
Please describe the functionality you suggest in more detail. Perhaps you can compose a small piece of code that explains the essence of your suggestion.
Re: Iterate records by index in TVirtualTable
Posted: Mon 30 Jul 2018 10:47
by DmitryV
Sometimes, is necessary to go through the dataset's records in a loop with a counter, like a the array of records (including, when the record's fields is pre-unknown).
Code, which i mean may by is similar... on an example of artless bubble sorting:
Code: Select all
var
VT : TVirtualTable;
i, j : Integer;
// Hipotetical class implementing of single VT's record, or just pointing to it
VTRecord : TVirtualTableRecord;
begin
...
for i := 0 to VT.RecordCount - 1 do
for j := 0 to VT.RecordCount - 2 do
if VT.Records[j].FieldByName('Sum').AsInteger <
VT.Records[j + 1].FieldByName('Sum').AsInteger then
begin
// Also, there could be a MoveTo method with a distance argument
// for moving the record taken on the index both up and down
VTRecord := VT.Records[j];
VT.Records[j] := VT.Records[j + 1];
VT.Records[j + 1] := VTRecord;
end;
end;
Re: Iterate records by index in TVirtualTable
Posted: Fri 31 Aug 2018 05:26
by MaximG
Thank you for the suggestion. You can leave your suggestions at our UserVoice page (
https://devart.uservoice.com/forums/104 ... components ), and if there are many votes for your suggestion, we will implement it.