TMSFNCGrid - Problem using checkboxes on group header rows

Hi,
I'm having problems using the AutoCheckGroup option in grouped grids. It's a bit of random behavior, but I've managed to find a sequence of steps that lead to this error.
1 - Click on button Group
2 - Click on the checkbox of the first group (works correctly)
3 - Collapse the first group
4 - Click on the checkbox for the second group - Doesn't work!

I've created a small example (
Grouping.zip (14.7 KB)
) using code from the TMS FMX/Grid/Grouping Demo.

I'm using the following versions
FNC UI Pack - v5.5.0.1
Delphi - Delphi 12 Version 29.0.51961.7529

I compiled the test application in FireMonkey and tested it in Win32

Hi,
i runned your demo under Win32 with Delphi 11.

The problem is here

procedure TForm130.Button1Click(Sender: TObject);
begin
  if not FGrouped then
  begin

    TMSFNCGrid1.SortData(1,sdAscending);

    TMSFNCGrid1.Options.Grouping.MergeHeader := true;
    TMSFNCGrid1.Options.Grouping.Summary := true;
    TMSFNCGrid1.Group(1); <<<<------ PROBLEM -----

    TMSFNCGrid1.GroupSum(6);
    TMSFNCGrid1.GroupAvg(5);
    TMSFNCGrid1.Options.Sorting.Mode := gsmNormal;
    TMSFNCGrid1.AddCheckBoxColumn(1);
  end
  else
  begin
    TMSFNCGrid1.UnGroup;
    TMSFNCGrid1.Options.Sorting.Mode := gsmNone;
    TMSFNCGrid1.UpdateGridCells;
  end;

  FGrouped := not FGrouped;
  Button2.Visible := FGrouped;
  if FGrouped then
    Button1.Text := 'Ungroup'
  else
    Button1.Text := 'Group';
end;

Each time you call TMSFNCGrid1.Group(1) all cells are cleared (as tms source code).
So .... Until TMS does not fix this i do one work around not so "elegant" but works good in order to keep the selection.
The demo with changes is here
Demo_2024-06-07.zip (9.8 KB)

Is very problaby that TMSFNCGrid has somenthing native to keep the selection who i miss (or i did not find).

Last suggestion is to made "read only" the columns with checkbox because if you try to edit the cell seems that the cell's editor does not control that there is (or not) the check box. In this case the edit field goes up on the checkbox and the result is not so good to see.

Best regard
Daniele

Hello Daniele

You've attached the same files I sent :slight_smile:

Best regard
Lília

Hi Lila,
is not the same ... here the differences (in case for any reasons the modified file was not added to zip file :sweat_smile:)

Type TChekRow = record
        Rcd : Integer;
     end;

in form declaration

  private
    { Private declarations }
    FGrouped: Boolean;

    CheckedBoxState : array of TChekRow;
    procedure SaveCheckBoxState;
    procedure RestoreCheckBoxState;
procedure TForm130.SaveCheckBoxState;
var I : Integer;
begin
  CheckedBoxState:=nil;
  for I:=0 to TMSFNCGrid1.RowCount - 1 do // Skip header
  begin
    if TMSFNCGrid1.CheckBoxState[1,I] then
    Begin
      SetLength(CheckedBoxState,Length(CheckedBoxState) + 1);
      CheckedBoxState[High(CheckedBoxState)].Rcd:=I
    end;
  end;
end;

procedure TForm130.RestoreCheckBoxState;
var I : Integer;
begin
  for I:=0 to High(CheckedBoxState) do
  begin
    TMSFNCGrid1.CheckBoxState[1,CheckedBoxState[I].Rcd]:=True;
  end;
end;

and the end in a grouping button click

  if not FGrouped then
  begin

    TMSFNCGrid1.SortData(1,sdAscending);

    TMSFNCGrid1.Options.Grouping.MergeHeader := true;
    TMSFNCGrid1.Options.Grouping.Summary := true;
    TMSFNCGrid1.Group(1);

    TMSFNCGrid1.GroupSum(6);
    TMSFNCGrid1.GroupAvg(5);
    TMSFNCGrid1.Options.Sorting.Mode := gsmNormal;
    TMSFNCGrid1.AddCheckBoxColumn(1);
    RestoreCheckBoxState; ***** line to add
  end
  else
  begin
    SaveCheckBoxState; ***** line to add
    TMSFNCGrid1.UnGroup;
    TMSFNCGrid1.Options.Sorting.Mode := gsmNone;
    TMSFNCGrid1.UpdateGridCells;
  end;

Hope can help you ...

Regards
Daniele

Hi Daniele

Thanks for your reply :slight_smile:

Unfortunately the changes you suggested don't solve the problem. The code you sent allows the status of the checkbox not to be lost when grouping/ungrouping the grid. But that's not the problem I described.

The problem I described occurs when you close a group, and try to click on the checkbox of the next group, it doesn't work properly, it doesn't select the checkboxes of that group...

Best regards

Lília

Hi Lilia,
i'm agree with you ...
The issue you report exist and appears "random".
I did several test and the problem was happend one / two times.
See this video
vsdc-sr 2024-06-15 11-27-16.zip (3.7 MB)
As you can see the problem is on the last group where the check box status is missing every time expand/collapse the node. Even, some time non happended in the video, if you click and check the collapsed group not all the rows are checked.
I think some others strange bheaviours can happend ....
If i can .... a good suggestion is that all this "cases" are handled by componet, This mean a great TMS work ....
Have a nice week end to all groups ...
Daniele

Hi Daniele,

Unfortunately this component has some problems... We use a lot of grids in our software, and in general they work well, however, when the grid is more complex, we need to put in more hours of development to get it to work properly.
In the case of the checkbox groups, we had managed to identify an error pattern that allowed us to get the software to work well. Similar to what you show in the video, when we clicked on the group's checkbox, we opened all the nodes, selected the rows corresponding to the group, and closed them again. This "solved" the problem, but in one of the last updates it stopped working...
As I can't wait any longer for a fix, I've implemented a solution that temporarily solves the problem using the OnCellAnchorClick event.
If anyone has the same problem, here's a suggestion:

  1. The grouped column is now filled with the html: <a href="0">Alfa Romeo</a>

  2. In the OnCheckBoxClick event, if the cell is a node, I call the OnCellAnchorClick event, using the href attribute (0 or 1) of the cell as the AAnchor parameter.

  3. In the OnCellAnchorClick event I make the code to select/unselect the checkboxes in the group and invert the href of the cell

The selection/unselection of the checkboxes is done manually, I don't use the AutoCheckGroup property.

Best regards

Lília

Hi Lilia,
thank you for your suggestion !!

Best regard
Daniele