Problem with Index and Filter - ClientDataSet

Problem with Index and Filter - ClientDataSet

Post by KotBu » Wed, 26 Nov 2003 00:08:10


Delphi 7, MSSQL 2000

I'm using following procedure to sort records (with ClientDataSet index)
when user click column title in DBGrid:

dm - DataModule
cdsTowar - ClientDataSet

procedure TForm1.DBGrid1TitleClick(Column: TColumn);
var
sNameA, sNameD : string;
begin
dm.cdsTowar.DisableControls;

sNameA := 'sort_' + Column.FieldName;
sNameD := sNameA + '_Desc';

if (dm.cdsTowar.IndexName = sNameD) or (dm.cdsTowar.IndexName <> sNameA)
then
begin
dm.cdsTowar.AddIndex(sNameA, Column.FieldName, [ixCaseInsensitive]);
dm.cdsTowar.IndexName := sNameA;
end
else
begin
dm.cdsTowar.AddIndex(sNameD, Column.FieldName, [ixCaseInsensitive,
ixDescending]);
dm.cdsTowar.IndexName := sNameD;
end;

dm.cdsTowar.EnableControls;

end;

It works fine - current record is always current after click on column
title.

There is a problem when I enable filtering:

cdsTowar.Filter := 'name like ''a%''';
cdsTowar.Filtered := true;

After this, when I click on column title in DBGrid the current record is
changed.

I tried to save current position with bookmark, but it's not working.
I don't want to use Locate to find proper record.

How can I prewent chanhing current record?
 
 
 

1. How can I filter a Master ClientDataSet from the Detail ClientDataset field values ?

2. Filtering Nested ClientDataSets

Hello,

I'm rather new using ClientDataSets and Delphi 6 for database
applications and I've been trying to get filters to work on a nested
dataset but to no avail.

Here is what I'm trying to do:

I create filter strings for the master and the detail datasets. I assign
the filter string to the master dataset, so that it will get filtered
first. I have also created an OnFiltered handler for it, in which I
attempt to get the current master dataset record and access its
NestedDataSet field and filter it. I would then like to test if this
detail dataset contains any records, as resulting from the application
of the filter and then decide whether to accept the master record after all.

This scheme does not work. Inspecting the datasets coming in the various
OnFiltered events, I can see that the detail dataset is not completely
available and its' RecordCount is 0. Also, it doesn't look like the
detail dataset is changing to point to the proper one nested in each
master record. I keep getting some sort of default record, looks like
the one linked to the last current in the master dataset.

So, has anybody had this sort of trouble before ? How do you handle
filtering in a nested dataset ?

Thanks in advance.

3. Date Filtering in ClientDataSets

4. Indexing Problems - Zoning Index Drafts.zip [0/8] - Zoning Index Drafts.zip [0/8]

5. Problem with calculations and multiple AND's in criteria

6. VB6 - Unusual problem on Help - Index filter

7. Struts + Servlet Filter + Global Forward problem + index.jsp ?

8. SQLRDD with Index File FILTER&BRWOSE Problem

9. Indexing Service filter daemon encountered a problem

10. Indexing Service filter daemon has encountered a problem

11. Indexing Service filter daemon has encountered a problem in CRM 3.

12. VB6 - Unusual problem in Help Index filter

13. Posting Changes with ClientDataSet + Provider Problems Sample Project

14. Clientdataset ApplyUpdates problem

15. Problem with ClientDataSet