Assign and Grid top record movement

Assign and Grid top record movement

Postby m227 » Tue 02 Aug 2011 21:23

Dear Sirs.

I found problem which manifests in moving grid top record position when assigning to another DataSet. I tried to introduce UNDO functionality to my vtOrder virtual table. In onBeforeEdit event i wrote such function.

Code: Select all
procedure TFormMain.vtOrderBeforeEdit(DataSet: TDataSet);
begin
  vtUndo.Assign(vtOrder);
end;

It works but when starting editing, the grid changes it's top record position and just edited record appears at the bottom of grid.
So It seems that Assigning a Virtual Table changes some it's properties (in my opinion it should not). Can you propose any fix?

Michal
m227
 
Posts: 55
Joined: Mon 06 Aug 2007 12:41

Postby AlexP » Wed 03 Aug 2011 07:43

Hello,

This problem may be connected with the sorting order of records in VirtualTable. Please check your sorting order, if it does not help, please send a sample demonstrating the problem to alexp*devart*com.
AlexP
Devart Team
 
Posts: 5525
Joined: Tue 10 Aug 2010 11:35

Not a sorting problem

Postby m227 » Wed 03 Aug 2011 17:03

Hello Alex,

I don't expect it is sorting problem - I do not order (sort) fields.
And in my opinion assigning DataSet1 to DataSet2 with
Code: Select all
DataSet2.Assign(DataSet1)

should not touch DataSet1 in any way (should leave it intact).
Am I wrong?

Michal
m227
 
Posts: 55
Joined: Mon 06 Aug 2007 12:41

Postby AlexP » Thu 04 Aug 2011 11:30

Hello,

The Assign method does not influence the source, and there are no changes in the records order, etc., in the basic DataSet.
Please send us a sample with filled VirtualTable table that demonstrates the behaviour you described to alexp*devart*com.
AlexP
Devart Team
 
Posts: 5525
Joined: Tue 10 Aug 2010 11:35

Saving to stream changes top record index of grid control

Postby m227 » Thu 04 Aug 2011 13:37

Dear Alex.

Before I send any code I'd like to present you my investigation. As I expected, assigning one VT to other (with Assign) uses SaveToStream/LoadFromStream. And digging deeper i found that saving to stream iterates record by record (as expected). At the end it assigns RecNo stored before so the cursor goes back to the same record as it was. Then it enables controls, as they were disabled during process.

And unfortunately, grid does not store top record position.
I mean the cursor is in the same record, but this record is scrolled down. It occurs when you scroll grid with scrollbar that first record shown is not first record of dataset but any further. And then place cursor in the middle of the grid records shown. And then try to assign visible vt to new one. The top record of grid changes.

If you still need example I will provide you with one.
Michal.
m227
 
Posts: 55
Joined: Mon 06 Aug 2007 12:41

Postby AlexP » Fri 05 Aug 2011 10:06

Hello,

We've reproduced the situation you described, but it is not a bug – this is a correct behaviour.
If such behaviour is not appropriate for you, you can use GetBookmark to save the current position before calling the Assign method and GotoBookmark to restore the position, but in this case the record will be lined up in the center of the grid.
AlexP
Devart Team
 
Posts: 5525
Joined: Tue 10 Aug 2010 11:35


Return to VirtualDAC