1
votes

enter image description here

Delphi 10.4 running on Windows 64, Android shows the same issue. I don't think it's a bug, but more a setting issue (I just can't find a setting)

If I have consecutive items whose Header is the same text, firemonkey version of TListView does not display the second item.

I can only find NativeOptions.Grouped=False, which is the closest thing I can find in terms of setting. Whether set to true/false made no difference.

Any pointers? Attached below is a Minimal Working Example, which demo the issue.

type
  TForm1 = class(TForm)
    ListView1: TListView;
    Button1: TButton;
    FDMemTable1: TFDMemTable;
    BindSourceDB1: TBindSourceDB;
    FDMemTable1CustomerID: TIntegerField;
    FDMemTable1CustomerName: TStringField;
    BindSourceDB2: TBindSourceDB;
    BindingsList1: TBindingsList;
    procedure Button1Click(Sender: TObject);
  private
    FLinkFillControlToField : TLinkFillControlToField;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.Button1Click(Sender: TObject);
begin
  with FDMemTable1 do
  begin
    Open;

    Append;
    FieldByName('CustomerID').AsInteger := 1;
    FieldByName('CustomerName').AsString := 'ABC';
    Post;

    Append;
    FieldByName('CustomerID').AsInteger := 2;
    FieldByName('CustomerName').AsString := 'XYZ';
    Post;

    Append;
    FieldByName('CustomerID').AsInteger := 3;
    FieldByName('CustomerName').AsString := 'XYZ';
    Post;
  end;

  if not Assigned(FLinkFillControlToField) then
  begin
    FLinkFillControlToField := TLinkFillControlToField.Create(BindingsList1);
    FLinkFillControlToField.Control := listview1;

    with FLinkFillControlToField do
    begin
      Category := 'Quick Bindings';
      Track := False;
      Direction := linkDataToControl;
      AutoActivate := False;
      AutoFill := True;
      BindSourceDB1.DataSource.Enabled := True;
      FillDataSource := BindSourceDB1;
    end;
  end;

  with FLinkFillControlToField do
  begin
    FillHeaderFieldName := 'CustomerName';

    with FillExpressions.AddExpression do
    begin
      SourceMemberName := 'CustomerID';
      ControlMemberName := 'Text1';
    end;
    with FillExpressions.AddExpression do
    begin
      SourceMemberName := 'CustomerName';
      ControlMemberName := 'Text2';
    end;
  end;
  FLinkFillControlToField.Active := True;
end;


object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 404
  ClientWidth = 763
  FormFactor.Width = 320
  FormFactor.Height = 480
  FormFactor.Devices = [Desktop]
  DesignerMasterStyle = 0
  object ListView1: TListView
    ItemAppearanceClassName = 'TDynamicAppearance'
    ItemEditAppearanceClassName = 'TDynamicAppearance'
    HeaderAppearanceClassName = 'TListHeaderObjects'
    FooterAppearanceClassName = 'TListHeaderObjects'
    Position.X = 16.000000000000000000
    Position.Y = 24.000000000000000000
    Size.Width = 561.000000000000000000
    Size.Height = 353.000000000000000000
    Size.PlatformDefault = False
    ItemAppearanceObjects.ItemObjects.ObjectsCollection = <
      item
        AppearanceObjectName = 'Text1'
        AppearanceClassName = 'TTextObjectAppearance'
        Appearance.Width = 223.000000000000000000
        Appearance.Height = 44.000000000000000000
      end
      item
        AppearanceObjectName = 'Text2'
        AppearanceClassName = 'TTextObjectAppearance'
        Appearance.Width = 208.000000000000000000
        Appearance.Height = 44.000000000000000000
        Appearance.PlaceOffset.X = 326.000000000000000000
      end>
    ItemAppearanceObjects.ItemEditObjects.ObjectsCollection = <
      item
        AppearanceObjectName = 'Text1'
        AppearanceClassName = 'TTextObjectAppearance'
      end>
  end
  object Button1: TButton
    Position.X = 592.000000000000000000
    Position.Y = 24.000000000000000000
    Size.Width = 161.000000000000000000
    Size.Height = 57.000000000000000000
    Size.PlatformDefault = False
    Text = 'Button1'
    OnClick = Button1Click
  end
  object FDMemTable1: TFDMemTable
    FetchOptions.AssignedValues = [evMode]
    FetchOptions.Mode = fmAll
    ResourceOptions.AssignedValues = [rvSilentMode]
    ResourceOptions.SilentMode = True
    UpdateOptions.AssignedValues = [uvCheckRequired, uvAutoCommitUpdates]
    UpdateOptions.CheckRequired = False
    UpdateOptions.AutoCommitUpdates = True
    Left = 576
    Top = 128
    object FDMemTable1CustomerID: TIntegerField
      FieldName = 'CustomerID'
    end
    object FDMemTable1CustomerName: TStringField
      FieldName = 'CustomerName'
      Size = 30
    end
  end
  object BindSourceDB1: TBindSourceDB
    DataSet = FDMemTable1
    ScopeMappings = <>
    Left = 576
    Top = 192
  end
  object BindSourceDB2: TBindSourceDB
    DataSet = FDMemTable1
    ScopeMappings = <>
    Left = 576
    Top = 248
  end
  object BindingsList1: TBindingsList
    Methods = <>
    OutputConverters = <>
    Left = 20
    Top = 5
  end
end
1
Could you write a minimal program reproducing the issue you have? Then edit your question to add that program source (.pas and .fmx). By the way, which platform are you using (Windows, Android...)? And wich Delphi version.fpiette
@fpiette, I've posted a minimal example. Windows32/64. android also same issue. Delphi 10.4. Previously I didn't post an example because I did not think it was a bug... it seems more like a setting issue. If the immediate subsequent header is different, then the header displays. If not, it disappears.Peter W.
I tested you code and it seems to be OK: I see 'ABC' header with record 1 and "XYZ" header with records 2 and 3. Please add a screen dump of what you get and draw an arrow showing what is wrong on it. I used Delphi 10.4.1 and made your code in a Windows application.fpiette
what I mean is that I'd like record 3 to have its own XYZ header. (see original post with screen capture)Peter W.
I have the exact same result as you. Are you sure that what you need is not a simple grid?fpiette

1 Answers

0
votes

I figured out that Headers are designed to work that way - it does not repeat if the consecutive header is exactly the same.

So I just moved the text into the 'main' section, so that it will repeat for every record.

Thanks for trying to help through your replies.