TMSFNCDataGrid closeup all grouped rows and count the groups

In a FNCDataGrid i use
Grid.UnGroup;
Grid.Group(1); // Username
to group all Data with column1.
How to close all groups, so i can see only the Usernames and then can select from which user i want to see more data.
How to count how many groups (Users) in the Grid to show this count in a Label.

You can call CollapseAllNodes, and with

TMSFNCDataGrid1.Root.GroupDictionary

You know how many groups are in total.

I use following Routines to Sho Data in my TMSFNCDataGrid named GrdAbz


{ -------------------------------------------------------------------------------
  Daten zum Anzeigen selektieren mit Jahr und Monat
  ------------------------------------------------------------------------------- }
procedure TfrmAbz.SelectDataGlobal;
Var
  lJahr, lMonat, lAngName, lKundenName, SQLString: String;
  GlobalIndex: Integer;
begin
  lJahr := cbbJahr.Text;
  lMonat := IntToStr(cbbMonat.ItemIndex + 1);
  if lMonat='0' then lMonat:= IntToStr(MonthOf(Now));

  lAngName := cbbAbzAngestellte.Text;
  lKundenName := cbbAbzKunde.Text;

  GlobalIndex := cbbAbzListen.ItemIndex;

  Case GlobalIndex of
     2:
      Begin
        // Nicht erledigte im Monat
        btnStbListe.Visible:=False;
        cbbAbzKunde.Visible := False;
        cbbAbzAngestellte.Visible := False;
        lblKunde.Visible := False;
        lblAngestellte.Visible := False;

        SQLString := 'SELECT * FROM Zeiterfassung ' + 'WHERE YEAR(lstDatum) = :lJahr ' + 'AND MONTH(lstDatum) = :lMonat AND Erledigt=0' + ' ORDER BY AngName, lstDatum';
        DM.qMySQL.SQL.Text := SQLString;
        DM.qMySQL.Params.ParamByName('lJahr').Value := lJahr;
        DM.qMySQL.Params.ParamByName('lMonat').Value := lMonat;
      End;
    3:
      Begin
        // Erledigte im Monat
        btnStbListe.Visible:=False;
        cbbAbzKunde.Visible := False;
        cbbAbzAngestellte.Visible := False;
        lblKunde.Visible := False;
        lblAngestellte.Visible := False;

        SQLString := 'SELECT * FROM Zeiterfassung ' + 'WHERE YEAR(lstDatum) = :lJahr ' + 'AND MONTH(lstDatum) = :lMonat AND Erledigt=1' + ' ORDER BY AngName, lstDatum';
        DM.qMySQL.SQL.Text := SQLString;
        DM.qMySQL.Params.ParamByName('lJahr').Value := lJahr;
        DM.qMySQL.Params.ParamByName('lMonat').Value := lMonat;
      End;
  End;

  DM.qMySQL.Open;
  ShowRecCount;
End;  



{ -------------------------------------------------------------------------------
  Anzeigen der Anzahl Datensätze die gefiltert sind
  ------------------------------------------------------------------------------- }
procedure TfrmAbz.ShowRecCount;
Var
  MitarbeiterCount, DataCount: Integer;
begin
  DataCount := GrdAbz.FilteredRowCount - 1;
  if DataCount < 0 then DataCount := 0;

  lblAnzahl.Font.Size := 14; // Größe des Textes für die Anzahl der Datensätze
  lblAnzahl.Caption := 'Anzahl Datensätze: ' + IntToStr(DataCount);

  if (cbbAbzListen.ItemIndex < 4) AND (cbbAbzListen.ItemIndex > -1) then
  begin
    GrdAbz.Ungroup;
    GrdAbz.group(1); // Nach Angestelltenname Gruppieren
    GrdAbz.GroupCount(1); // Zeigt die Anzahl der Einträge pro Gruppe an
    GrdAbz.CollapseAllNodes; // Alle Gruppen einklappen
    MitarbeiterCount := GrdAbz.Root.GroupDictionary.Count;
    lblAnzahl.Caption := lblAnzahl.Caption + '                Anzahl der Mitarbeiter: ' + IntToStr(MitarbeiterCount);
  end;
end;

the First time i call SelectDataglobal the Grid shows the data without grouping.
After se second call there are no Data shown and
after the third call the data is shown in groups like expected.
The naxt Call did show nothing
and the next Call show it with grouping.

Could you see somthing i do wrong, maybe the ungroup.
But without ungroup Grouping do not work.

Could you try to isolate this, for example in one of our demos? We have tried to reproduce this here but couldn't so far.

I reduce the problem to one RefreshButton procedure.

procedure TfrmAbz.btnRefreshClick(Sender: TObject);
Var 
MitarbeiterCount:Integer;
begin
  SelectDataGlobal; // SQL-Select

  GrdAbz.Ungroup;
  GrdAbz.group(1); // Nach Angestelltenname Gruppieren
  GrdAbz.GroupCount(1); // Zeigt die Anzahl der Einträge pro Gruppe an
  GrdAbz.CollapseAllNodes; // Alle Gruppen einklappen

  MitarbeiterCount := GrdAbz.Root.GroupDictionary.Count;
  lblAnzahl.Caption := lblAnzahl.Caption + '                Anzahl der Mitarbeiter: ' + IntToStr(MitarbeiterCount);
end;

Without Grouping the first Time i get 5 Entries for the First Mitarbeiter

After calling this Refresh Button the Gouping is correct.
After calling this Refresh Button again, there are only 4 Mitarbeiter shown (The first Row is gone)
For the second and Third Mitarbeiter the grouping is 2 count lower.
You can see it in this 3 Pictures.



We can't reproduce this issue. We've tried this on our of our demos (Customs FireDac SQLite), but couldn't reproduce the issue. The ungrouping, grouping all works as expected. Could you test the code you use on one of our demos or send a sample which we'll be able to reproduce the issue with?