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);
sNameA, sNameD : string;

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

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



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

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

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


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 [0/8] - Zoning Index [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