0

I'm using TClientDataset.CloneCursor to implement different views of the same data. I have a master dataset, and several clones, each of which contains a different subset of the master dataset's fields. But when I try to display data from the clones, they come up empty. The master dataset is populated with data correctly, and the clone datasets' CloneSource property is pointing to the correct dataset, but if I put two grids side-by-side, one showing the master and the other linked to a clone view, the clone view one will be blank.

Any idea what can cause this?

4

1 回答 1

2

好的,既然你没有任何代码,那我给你写一些。这听起来像你在说什么,它适用于我的机器。所以现在你告诉我你在做什么不同。将TClientDataSetTDataSourceTDBGrid各放两个。将它们连接起来并正确命名:

var
  idField: TFieldDef;
  stringField: TFieldDef;
begin
  idField := ds1.FieldDefs.AddFieldDef;
  idField.DataType := ftInteger;
  idField.Name := 'id';

  stringField := ds1.FieldDefs.AddFieldDef;
  stringField.DataType := ftString;
  stringField.Size := 10;
  stringField.Name := 'name';

  ds1.CreateDataSet;
  ds1.InsertRecord([1, 'Jim McKeeth']);
  ds1.InsertRecord([2, 'Mason Wheeler']);
  ds1.InsertRecord([3, 'Jeff Atwood']);

  ds2.CloneCursor(ds1, true);
  ds2.Filter := 'id=1';
  ds2.Filtered := True;
end;
于 2008-12-20T08:47:40.490 回答