Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Novice question re use of dataset find in grid
Fri, May 22 2015 10:15 PMPermanent Link

StewCam

I have a dataset loaded to a grid but am struggling with correct usage thereafter. Here is some code using EWB 1.05 b3:

procedure TFormMain.FormMainCreate(Sender: TObject);
var
 DatCol: TDataColumn;
begin
 DS.Close;
 DS.Columns.Clear;
 DatCol := DS.Columns.Add;
 DatCol.Name := 'id';
 DatCol.DataType:=dtInteger;
 DatCol := DS.Columns.Add;
 DatCol.Name := 'name';
 DatCol.DataType:=dtString;
 DatCol.Length:=255;
 DS.Open;
 DS.Params.Clear;
 DS.Params.Add('id=all');
 Database.BaseUrl := 'load.php';
 Database.Load(DS);
end;

procedure TFormMain.BtnFindClick(Sender: TObject);
begin
 with DS do
 begin
   Columns['name'].SortDirection := sdAscending;
   SortCaseInsensitive := True;
   Sort;
   InitFind;
   Columns['name'].AsString := 'Fred';
   if Find(False,True) then
     ShowMessage('Not found')
   else
     ShowMessage('Found');
 end;
end;

When I click the Find button, grid data is sorted but then the find term 'Fred' is inserted into the name column in a new row at the top of the grid. There is also an error message: "Unable to get property 'tdatavalue_fmodified' of undefined or null reference Line 3605". I presume I am overlooking something simple.
Sat, May 23 2015 9:35 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com


<< When I click the Find button, grid data is sorted but then the find term
'Fred' is inserted into the name column in a new row at the top of the grid.
>>

This is normal - finds are handled in-line as a "new" row, so they'll cause
dataset changes in any data-bound controls like a grid.  If you don't want
this behavior, then you can just bracket the find operation with a:

MyDataSet.DisableControls;
try
  // Find
finally
  MyDataSet.EnableControls;
end;

<< There is also an error message: "Unable to get property
'tdatavalue_fmodified' of undefined or null reference Line 3605". I presume
I am overlooking something simple. >>

Can you send me (timyoung@elevatesoft.com) what you're using to get that
error ?  I'll have to look into this further, since it appears to be a bug.

Thanks,

Tim Young
Elevate Software
www.elevatesoft.com


Tue, May 26 2015 12:47 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Per email, the issue was with a double-column-add, thus one of the columns
was missing a data type.

I've added fixes for EWB 1 and 2 that catch this at dataset open and issue
an exception, which is clearer than what was occurring.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, May 26 2015 6:02 PMPermanent Link

StewCam

Thanks. Catching the error will be a useful addition but mea culpa - I should have picked it up.
Image