TMSFNCGrid Hide/Unhide Row Issue

You can attach it here at this post.

Test.js (4.0 KB) Test.pas (1.8 KB) Tester.dpr (217 Bytes) Tester.dproj (82.5 KB)

please rename the Test.js as Test.fmx. (fmx file is not supported)

Hi,

Please zip the files, and upload the zip, because of security issues we cannot download JS extensions.

Test.zip (8.0 KB)

zipped the files. Please look into it.

The ZIP file you have attached is corrupt. No sure what is going on, but I cannot open it.

GridChildRow.zip (8.6 KB)

Please try this one. Thanks

When you are working with hidden rows, you need to use Grd.DisplToRealRow(ARow) to convert the row index to the correct row. Initially Row 1 is Row 1 and Row 7 is Row 7, but when expanding Row 1, you are adding new rows, which means that Row 7 is then Row9, when clicking Row 7, you get index 9, which needs to be converted back to Row 7 to know if the row is expanded or not, based on the original objects you have entered.

procedure TfrmTest.GrdFixedCellClick(Sender: TObject; ACol, ARow: Integer);
var
Ptr: ^Boolean;
r: Integer;
begin

  r := Grd.DisplToRealRow(ARow);

  Grd.BeginUpdate;
  if Grd.IsBitmap(ACol,ARow) then
  begin
    if Grd.GetBitmapName(ACol,ARow) = 'Plus' then
    begin
      Grd.AddBitmap(ACol,ARow,'Minus');
      Ptr := Pointer(Grd.Objects[ACol,r]);
      if Ptr^ then
      begin
        Grd.InsertRows(r + 1,2);
        Ptr^ := False;
        Grd.Objects[0,r] := TObject(Ptr);
      end
      else
        Grd.UnHideRows(r + 1,2);
    end
    else
    begin
      Grd.AddBitmap(ACol,r,'Plus');
      Grd.HideRows(r + 1,2);
    end;
  end;
  Grd.EndUpdate;
end;

Thanks for the reply. This code works fine if we click on Row 1 and then Row 7. But if we click on Row 1(adding 2 rows) and then click on the same Row 1(Hiding the inserted rows) and now if we click on Row 7 it messes up.

As per your logic RealToDisplRow should give Row No 9, but its giving Row No 5.

In the code snippet, I'm using DisplToRealRow, not RealToDisplRow

If I use DisplToRealRow, Row No 1 working Fine. Row No 7 is not working.Please check the below steps:

  1. click on Row 1(adding 2 rows).
  2. click on the same Row 1(Hiding the inserted rows).
  3. click on Row 7 (Not works)

I think the code is fundamentally wrong when using hidden rows, because you are initially adding a pointer to an object, but when inserting rows the pointer to the object is not correct anymore. hidden rows are handled differently internally and therefore do not count when removing and inserting rows. When further finetuning the code for this particular case, I only see issues rising when applying this in other cases. To workaround this complex structure I suggest to collapse rows using a rowheight of 0 instead. Alternatively, If you want to build a tree view, perhaps you could consider using our multi-column treeview instead.

if Grd.RowHeight := 0 is given to hide rows, it seems ok in Windows OS; but in MacOS it looks as in the attached file(look below the row "Share Capital"). I cant use treeview as I have to merge cells in some places.

We have applied a fix for the macOS rowheight = 0 issue. The next version will address this.

When can I expect the next version?

Next version will be released in the coming days

Shall I know the approx. date of release as 2 weeks passed?

The release was done on March 24th