TTMSFMXGrid Header Checkboxes on Filtered entries

Hi,

So I have a TTMSFMXGrid with a Header Checkbox on [0,0]. Column[0] is a Fixed Column and is my designated checkbox column. When i filter the grid on conditions on the other columns, clicking the header checkbox does not check/uncheck all of the filtered rows.

I was able to work around this by defining my own checking/unchecking procedure via OnCellCheckBoxClick. So, I filter my grid, click on the header checkbox (so it checks all the filtered entries). But when I reset the filters (remove filters), the entries that satisfied the filter are checked (as expected) but the first X rows (depending on how many rows the filtered grid was) are also checked.

Say I have 15 rows, i filter them which results to 5 rows (real row 1, 10, 11, 12, 15). I click the header checkbox, and they are checked. i remove the filter (no filters in effect so it shows all rows) and now i have rows 1, 2, 3, 4, 5, 10, 11, 12 and 15 checked. I'm kinda hoping i only have 1, 10, 11, 12 and 15 checked.

I need a little help as I'm not sure if I'm understanding how these (checkboxes, filters, real/display rows) work.
Thanks in advance!

There is at this moment not a built-in behavior that will automatically check/uncheck checkboxes in rows when a header checkbox is clicked. This should be handled at application level when desired.

I could not see there is an issue when accessing checkboxes in hidden (filtered) rows.

Sample test code:

begin
   tmsfmxgrid1.AddCheckBox(0,0,false);
   tmsfmxgrid1.AddCheckBox(0,1,false);
   tmsfmxgrid1.AddCheckBox(0,2,false);
   tmsfmxgrid1.AddCheckBox(0,3,false);
   tmsfmxgrid1.HideRow(1);

   tmsfmxgrid1.CheckBoxState[0,1] := true;
   tmsfmxgrid1.CheckBoxState[0,2] := true;

   tmsfmxgrid1.UnHideRow(1);
end;

which works here as expected.
Thank you for your reply.

However, I'm not using HideRow/Unhide row. just the built in filter of TMSFMXGrid. Except for the code to do the check-all/uncheck all in OnCellCheckBoxClick, I haven't done anything programmatically. I just did the following:

1. Filter the grid using the built in filter (which results in 5 entries: real row 1, 10, 11, 12, 15)
2. Click the Checkbox in the fixed cell [0,0] which calls OnCellCheckBoxClick to check all visible rows
3. I remove the filter on the grid by selecting (All) on the built-in filter
4. I now have rows 1, 2, 3, 4, 5, 10, 11, 12, and 15 checked.

this is may OnCellCheckBoxClick code for ref:


procedure TForm.GridCellCheckBoxClick(Sender: TObject; ACol, ARow: Integer; Cell: TFmxObject);
var
  RRow : Integer; //real
  Chkd : boolean;
  DRow : integer; //display
begin
  if (ACol = 0) and (ARow = 0) then
  begin
    Chkd := (Cell as TTMSFMXCheckGridCell).CheckBox.IsCheckedProg;

    for DRow := 1 to Grid.RowCount - 1 do
    begin
      RRow := Grid.DisplToRealRow(DRow);
      if Grid.IsCheckBox(0, RRow) then
        Grid.CheckBoxState[0, RRow] := Chkd;
    end;
  end;
end;


Internally, filtering uses row hiding/unhiding.

In my test code, I didn't use DisplToRealRow. Please try without.