1
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 loaded the data into it manually...
Cds_NaMenu.Append;
Cds_NaMenu.FieldByName('DISPONIBILIDADE').AsInteger := 1;
Cds_NaMenu.Post;
Well. The problem happens when I filter the Memtable. At this very moment it loses all the data. Although I remove the filter, it goes back to Recordcount = 0. Even saving the data in an xml, they are not visible. It’s like he actually 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.
I tested with the same routine that you posted and it worked, not such finishing Fdmemtable object at some point?
– Jefferson Rudolf
I know it’s not an answer, it’s an assumption, but maybe you’re not filling in the complete data (either you’re missing a primary key, or you don’t fill in the index field well) and only validate internally when the filter works...
– Tiago Rodrigues
I also tested exactly with the same code you posted and it worked perfectly.
– Vinicius