FDMemTable losing data when using Filter

0

I created an FDMemTable, at runtime, with the following structure:

Cds_NaMenu := TFDMemTable.Create(nil);
Cds_NaMenu.FieldDefs.Add('ID', ftInteger);
Cds_NaMenu.FieldDefs.Add('MN_TELA_CODIGO', ftInteger);
Cds_NaMenu.FieldDefs.Add('MN_MENU_PESQUISA', ftString, 500);
Cds_NaMenu.FieldDefs.Add('DISPONIBILIDADE', ftInteger);
Cds_NaMenu.IndexDefs.Add('Ordem', 'MN_TELA_CODIGO', []);
Cds_NaMenu.CreateDataSet;
Cds_NaMenu.LogChanges := False;
Cds_NaMenu.IndexName := 'Ordem';

I manually loaded the data into it ...

Cds_NaMenu.Append;
Cds_NaMenu.FieldByName('DISPONIBILIDADE').AsInteger := 1;
Cds_NaMenu.Post;

Well. The problem happens when I filter MemTable. At this very moment he loses all the data. Even though I remove the filter, it returns to RecordCount = 0. Even saving the data in an xml, they are not visible. It's as if he really had lost the data in memory.

_recCount := Cds_NaMenu.RecordCount; // Result = 867;
Cds_NaMenu.Filter := 'DISPONIBILIDADE=1 AND MN_MENU_PESQUISA like ' + QuotedStr('%' + sTexto + '%');
Cds_NaMenu.Filtered := True;
_recCount := Cds_NaMenu.RecordCount; // Result = 0;
Cds_NaMenu.Filtered := False;
Cds_NaMenu.Filter := '';
_recCount := Cds_NaMenu.RecordCount; // Result = 0;

PS: With ClientDataSet the same code works perfectly.

    
asked by anonymous 01.08.2017 / 22:28

1 answer

0

I know this is not an assumption, but you may not be filling in the complete data (or a primary key is missing, or you do not fill in the Index field well) and internally validate only when the filter acts ... < p>     

02.08.2017 / 13:28