开发者

StatusFilter on ClientDataSet

I'm having some difficulties using ClientDataSet.StatusFilter := [usDeleted].

It doesn't do anything. I'm having my ClientDataSet hooked up to a Provider.

When applying the StatusFilter the DataSet does not display the deleted records.

It just shows the records as before applying the StatusFilter.

On the other hand. If I use ClientDataSet.CreateDataSet which isn't hooked up to a provider and only use the ClientDataSet as an in-memory DataSet then the StatusFilter works as described in the documentation.

The DataSet only displayes the deleted records.

The ClientDataSet.UpdateStatus also shows the correct status usDeleted.

The only way I can get my first ClientDataSet that is hooked up to a provider to display the deleted records is by using the ClientDataSet.Delta property. But this doesn't allow me to Revert a deleted record.

//Note: cds.LogChanges = true
cds := TClientDataSet.Create(nil);
cds.Da开发者_JAVA百科ta := MyClientDataSet.Delta;
cds.First;

while not cds.eof do
begin
  case cds.UpdateStatus of    
    usModified:    
      begin    
        ShowMessage('Modified');    
        cds.RevertRecord;    
      end;
    usInserted: ShowMessage('Inserted');
    usDeleted: ShowMessage('Deleted');    
  end; 

  cds.Next;    
end;    

cds.Free;

What am I doing wrong?


The code you describe

ClientDataSet1.StatusFilter := [usDeleted];

is the correct way to include in your current ClientDataSet view only those records that have been deleted. I do not understand why it is not working for you, as I use this approach in my code all the time and it has never failed. The only thing I can think of is that you may have called ApplyUpdates or CancelUpdates prior to setting the StatusFilter property, or you may have LogChanges set to False (it's default is True).

By the way, to cancel status filter set it to an empty set, like this:

ClientDataSet1.StatusFilter := [];

That will include inserted, modified, and unmodified records in your view. The deleted records will not appear in the current view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜