Why is my cloned dataset empty?

I am using TClientDataset.CloneCursor to implement different views of the same data. I have a base dataset and several clones, each containing a different subset of the fields of the base dataset. But when I try to display data from clones, it appears blank. The master dataset is populated with data correctly, and the cloneSource property of the clone data points to the correct dataset, but if I place two grids side by side, one showing the master and the other linked to the clone view, the clone of one is empty.

Any idea what might be causing this?

0


source to share


1 answer


Ok, since you don't have the code, I'll write you something. This is similar to what you are talking about and works on my machine. So now you are telling me what you are doing differently. Place two each of TClientDataSet , TDataSource , TDBGrid down. Connect them and name them correctly:



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;

      

+2


source







All Articles