Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 1985 - Problem that TVirtualDBData.Load raises error Selected Row must be >= -1 on a filtered dataset
Summary: Problem that TVirtualDBData.Load raises error Selected Row must be >= -1 on a...
Status: RESOLVED FIXED
Alias: None
Product: TeeGrid for Delphi
Classification: Unclassified
Component: Grid (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: david berneda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-06 17:54 EST by Zlatko Kropf
Modified: 2018-02-15 08:58 EST (History)
0 users

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zlatko Kropf 2018-02-06 17:54:58 EST
Environment:

I am using Spring4d to hold/manipulate data and represent it as dataset using Spring.Data.ObjectDataSet. TObjectDataSet is a descendant of TDataSet and can hold data in an iList. 

On a sample form I have a grid, data is linked from the TObjectDataset. Everything works fine until I put a OnFilterRecord method on my data which filters the data.

If any data passes the filter the grid displays it normally. However, when no records conform to criteria (the dataset is empty) then an exception is raised stating, "Error: Selected Row must be >= -1".

I have traced the error to unit Tee.Grid.Selecton (row 506) - 

Assert(Value>=-1,'Error: Selected Row must be >= -1');


But the cause originates elsewhere:

unit Tee.GridData.DB;

Method procedure TVirtualDBData.Load(const AColumns:TColumns);

  if IDataSet<>nil then
  begin
    TryRelinkFields;

    if KnownCount then    // Returns True
       ChangeSelectedRow(DataSetRecNo-1)  
             //  DataSetRecNo returns -1 --> calls ChangeSelectedRow(-2)
    else
    if Empty then
       ChangeSelectedRow(-1)
    else
       ChangeSelectedRow(0);
  end;

When OnFilterRecord returns no records the call to ChangeSelectedRow wants to set the selected row to -2, causing the exception.
Comment 1 david berneda 2018-02-15 08:58:37 EST
Fixed