Alternating Colours on TwwLayoutgrid

Comments

3 comments

  • Roy Woll

    I can't reproduce your problem with our demos. Please provide a reproduceble project. You can access the help file by clicking on Help | Third Party Help | FirePower

    0
    Comment actions Permalink
  • Leonard Mann

    Thanks for the reply, Roy.

    I can recreate the same issue by modifying your GridLayoutRecView.pas in your MainDemo Project.

    If I modify the overridestyle.data.BackColor to yelllow and the overridestyle.data.AlternatingColor to green, every odd row is yellow and every even row is the 'slate' colour of your original demo. If you try this on your side do the alternating colours work properly? Perhaps I don't have the most current version of Firepower.

    The version I am using is 'FirePower X3 for RAD Studio 12.0 Athens'.

    I found the Firepower help documentation, thank you.

    0
    Comment actions Permalink
  • Leonard Mann

    Hi Roy,

    I have created a small project with checkboxes to set the alternating colours for a TwwDataGrid and a TwwLayoutGrid. I don't know how to attach the project zip file but I am including a screenshot, the .pas and .dfm text.

    I would expect setting the AlternatingColor on either component would set the 'odd' rows to the alternate colour and setting the BackColor would set everything else to the back colour. However, when I set the Alternating colour to yellow, the 'odd' rows of the Datagrid are the only rows that turn yellow. No rows on the LayoutGrid change colour. When I set the Back colour to lime, the odd rows on the LayoutGrid turn lime but ALL the rows on the Datagrid turn lime.

    Am I setting the properties correctly or am I missing something.

    Any feedback is greatly appreciated.



    unit Unit2;

    interface

    uses
      System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
      FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
      FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Param,
      FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf,
      FireDAC.Stan.StorageBin, Data.Bind.EngExt, Fmx.Bind.DBEngExt, System.Rtti,
      System.Bindings.Outputs, Fmx.Bind.Editors, Data.Bind.Components, FMX.StdCtrls,
      FMX.wwImageControl, FMX.Layouts, FMX.Controls.Presentation, FMX.wwLayoutGrid,
      FMX.wwLayouts, Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client,
      Data.Bind.DBScope, FMX.wwColumnTypes, FMX.wwDataGrid, FMX.wwBaseGrid;

    type
      TForm2 = class(TForm)
        bsCustomer: TBindSourceDB;
        FDMTCustomer: TFDMemTable;
        FDMTCustomerCustomerNo: TIntegerField;
        FDMTCustomerCompanyName: TStringField;
        BindingsList1: TBindingsList;
        LinkPropertyToFieldText: TLinkPropertyToField;
        LinkPropertyToFieldText2: TLinkPropertyToField;
        LinkPropertyToFieldText3: TLinkPropertyToField;
        LinkPropertyToFieldText4: TLinkPropertyToField;
        wwDataGrid1: TwwDataGrid;
        wwDataGrid1CustomerNo: TwwGridColumn;
        wwDataGrid1CompanyName: TwwGridColumn;
        LinkPropertyToFieldText5: TLinkPropertyToField;
        LinkPropertyToFieldText6: TLinkPropertyToField;
        wwLayoutGrid1: TwwLayoutGrid;
        wwLayoutGrid1RecordPanel: TwwLayoutPanel;
        Label1: TLabel;
        Label2: TLabel;
        LinkPropertyToFieldText7: TLinkPropertyToField;
        LinkPropertyToFieldText8: TLinkPropertyToField;
        Panel1: TPanel;
        CheckBox1: TCheckBox;
        CheckBox2: TCheckBox;
        procedure FormCreate(Sender: TObject);
        procedure LoadData;
        procedure CheckBox2Change(Sender: TObject);
        procedure CheckBox1Change(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;

    var
      Form2: TForm2;

    implementation

    {$R *.fmx}

    procedure TForm2.CheckBox1Change(Sender: TObject);
    begin
      if (Sender as TCheckBox).isChecked then
      begin
        wwLayoutGrid1.OverrideStyleSettings.Data.AlternatingColor := TAlphaColorRec.yellow;
        wwDataGrid1.OverrideStyleSettings.Data.AlternatingColor := TAlphaColorRec.yellow;
      end
      else
      begin
        wwLayoutGrid1.OverrideStyleSettings.Data.AlternatingColor := TAlphaColorRec.null;
        wwDataGrid1.OverrideStyleSettings.Data.AlternatingColor := TAlphaColorRec.null;
      end;
    end;

    procedure TForm2.CheckBox2Change(Sender: TObject);
    begin
      if (Sender as TCheckBox).isChecked then
      begin
        wwLayoutGrid1.OverrideStyleSettings.Data.BackColor := TAlphaColorRec.lime;
        wwDataGrid1.OverrideStyleSettings.Data.BackColor := TAlphaColorRec.lime;
      end
      else
      begin
        wwLayoutGrid1.OverrideStyleSettings.Data.BackColor := TAlphaColorRec.null;
        wwDataGrid1.OverrideStyleSettings.Data.BackColor := TAlphaColorRec.null;
      end;
    end;

    procedure TForm2.FormCreate(Sender: TObject);
    begin
       LoadData;
    end;

    procedure TForm2.LoadData;
    begin
      FDMTCustomer.Close;
      FDMTCustomer.Open;

      FDMTCustomer.Insert;
      FDMTCustomer.FieldByName('CustomerNo').AsInteger := 1;
      FDMTCustomer.FieldByName('CompanyName').AsString := 'Company 1';
      FDMTCustomer.Post;

      FDMTCustomer.Insert;
      FDMTCustomer.FieldByName('CustomerNo').AsInteger := 2;
      FDMTCustomer.FieldByName('CompanyName').AsString := 'Company 2';
      FDMTCustomer.Post;

      FDMTCustomer.Insert;
      FDMTCustomer.FieldByName('CustomerNo').AsInteger := 3;
      FDMTCustomer.FieldByName('CompanyName').AsString := 'Company 3';
      FDMTCustomer.Post;

      FDMTCustomer.Insert;
      FDMTCustomer.FieldByName('CustomerNo').AsInteger := 4;
      FDMTCustomer.FieldByName('CompanyName').AsString := 'Company 4';
      FDMTCustomer.Post;
    end;

    object Form2: TForm2
      Left = 0
      Top = 0
      Caption = 'Form2'
      ClientHeight = 479
      ClientWidth = 640
      FormFactor.Width = 320
      FormFactor.Height = 480
      FormFactor.Devices = [Desktop]
      OnCreate = FormCreate
      DesignerMasterStyle = 0
      object wwDataGrid1: TwwDataGrid
        Touch.InteractiveGestures = [Pan]
        Align = Bottom
        EnableDragHighlight = False
        Position.Y = 297.000000000000000000
        Size.Width = 640.000000000000000000
        Size.Height = 135.000000000000000000
        Size.PlatformDefault = False
        TabOrder = 3
        DataSource = bsCustomer
        LineAttributes.LineOpacity = 1.000000000000000000
        Options = [dgEditing, dgTitles, dgIndicator, dgColumnResize, dgColumnReorder, dgTabs, dgConfirmDelete, dgCancelOnExit, dgWordWrap, dgAlternatingRow]
        object wwDataGrid1CustomerNo: TwwGridColumn
          FieldName = 'CustomerNo'
          Title = 'Customer No'
          Width = 85
          Index = 0
        end
        object wwDataGrid1CompanyName: TwwGridColumn
          FieldName = 'CompanyName'
          Title = 'Company Name'
          Width = 317
          Index = 1
        end
      end
      object wwLayoutGrid1: TwwLayoutGrid
        Touch.InteractiveGestures = [Pan]
        Align = Client
        CanFocus = True
        OverrideStyleSettings.Data.AlternatingColor = claYellow
        Size.Width = 640.000000000000000000
        Size.Height = 297.000000000000000000
        Size.PlatformDefault = False
        TabOrder = 4
        PaintOptions.PaintEfficiency = BufferRecords
        Options = [cgoIndicator, cgoRowSelect, cgoConfirmDelete, cgoAllowDelete, cgoCancelOnExit, cgoAlternatingRow, cgoAllowControlClickWhenChangeRows, cgoTransparentEditorsForInactiveCell, cgoTransparentEditorsForActiveCell]
        RowCount = 5
        DataSource = bsCustomer
        RowHeight = 57
        object Label1: TLabel
          Position.X = 80.000000000000000000
          Position.Y = 8.000000000000000000
          TabOrder = 1
        end
        object Label2: TLabel
          Position.X = 80.000000000000000000
          Position.Y = 31.000000000000000000
          TabOrder = 0
        end
      end
      object Panel1: TPanel
        Align = Bottom
        Position.Y = 432.000000000000000000
        Size.Width = 640.000000000000000000
        Size.Height = 47.000000000000000000
        Size.PlatformDefault = False
        TabOrder = 5
        object CheckBox1: TCheckBox
          Position.X = 56.000000000000000000
          Position.Y = 8.000000000000000000
          Size.Width = 193.000000000000000000
          Size.Height = 19.000000000000000000
          Size.PlatformDefault = False
          TabOrder = 1
          Text = 'Set Alternating Colour to Yellow'
          OnChange = CheckBox1Change
        end
        object CheckBox2: TCheckBox
          Position.X = 320.000000000000000000
          Position.Y = 8.000000000000000000
          Size.Width = 225.000000000000000000
          Size.Height = 19.000000000000000000
          Size.PlatformDefault = False
          TabOrder = 0
          Text = 'Set Back Colour to Lime'
          OnChange = CheckBox2Change
        end
      end
      object bsCustomer: TBindSourceDB
        DataSet = FDMTCustomer
        ScopeMappings = <>
        Left = 208
        Top = 64
      end
      object FDMTCustomer: TFDMemTable
        Active = True
        FieldDefs = <
          item
            Name = 'CustomerNo'
            DataType = ftInteger
          end
          item
            Name = 'CompanyName'
            DataType = ftString
            Size = 40
          end>
        IndexDefs = <>
        FetchOptions.AssignedValues = [evMode]
        FetchOptions.Mode = fmAll
        FormatOptions.AssignedValues = [fvMaxBcdPrecision, fvMaxBcdScale]
        FormatOptions.MaxBcdPrecision = 2147483647
        FormatOptions.MaxBcdScale = 2147483647
        ResourceOptions.AssignedValues = [rvPersistent, rvSilentMode]
        ResourceOptions.Persistent = True
        ResourceOptions.SilentMode = True
        UpdateOptions.AssignedValues = [uvUpdateChngFields, uvUpdateMode, uvLockMode, uvLockPoint, uvLockWait, uvRefreshMode, uvFetchGeneratorsPoint, uvCheckRequired, uvCheckReadOnly, uvCheckUpdatable]
        UpdateOptions.LockWait = True
        UpdateOptions.FetchGeneratorsPoint = gpNone
        UpdateOptions.CheckRequired = False
        StoreDefs = True
        Left = 24
        Top = 56
        Content = {
          4144425310000000B6010000FF00010001FF02FF0304001E0000004300750073
          0074006F006D006500720044006100740061004D0065006D0005001E00000043
          007500730074006F006D006500720044006100740061004D0065006D00060000
          000000070000080032000000090000FF0AFF0B04001400000043007500730074
          006F006D00650072004E006F0005001400000043007500730074006F006D0065
          0072004E006F000C00010000000E000D000F0001100001110001120016000000
          43007500730074006F006D006500720020004E006F0013000114000115000116
          000117001400000043007500730074006F006D00650072004E006F00FEFF0B04
          001600000043006F006D00700061006E0079004E0061006D0065000500160000
          0043006F006D00700061006E0079004E0061006D0065000C00020000000E0018
          001900280000000F000110000111000112001800000043006F006D0070006100
          6E00790020004E0061006D00650013000114000115000117001600000043006F
          006D00700061006E0079004E0061006D0065001A0028000000FEFEFF1BFEFF1C
          FEFF1DFEFEFEFF1EFEFF1F2000A9130000FF21FEFEFE0E004D0061006E006100
          6700650072001E00550070006400610074006500730052006500670069007300
          74007200790012005400610062006C0065004C006900730074000A0054006100
          62006C00650008004E0061006D006500140053006F0075007200630065004E00
          61006D0065000A0054006100620049004400240045006E0066006F0072006300
          650043006F006E00730074007200610069006E00740073001E004D0069006E00
          69006D0075006D00430061007000610063006900740079001800430068006500
          63006B004E006F0074004E0075006C006C00140043006F006C0075006D006E00
          4C006900730074000C0043006F006C0075006D006E00100053006F0075007200
          63006500490044000E006400740049006E007400330032001000440061007400
          610054007900700065001400530065006100720063006800610062006C006500
          120041006C006C006F0077004E0075006C006C00080042006100730065000E00
          430061007000740069006F006E0014004F0041006C006C006F0077004E007500
          6C006C0012004F0049006E0055007000640061007400650010004F0049006E00
          570068006500720065000C004F0049006E004B00650079001A004F0072006900
          670069006E0043006F006C004E0061006D00650018006400740041006E007300
          690053007400720069006E0067000800530069007A006500140053006F007500
          720063006500530069007A0065001C0043006F006E0073007400720061006900
          6E0074004C00690073007400100056006900650077004C006900730074000E00
          52006F0077004C006900730074001800520065006C006100740069006F006E00
          4C006900730074001C0055007000640061007400650073004A006F0075007200
          6E0061006C001200530061007600650050006F0069006E0074000E0043006800
          61006E00670065007300}
        object FDMTCustomerCustomerNo: TIntegerField
          DisplayLabel = 'Customer No'
          DisplayWidth = 10
          FieldName = 'CustomerNo'
          Origin = 'CustomerNo'
          ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
        end
        object FDMTCustomerCompanyName: TStringField
          DisplayLabel = 'Company Name'
          DisplayWidth = 40
          FieldName = 'CompanyName'
          Origin = 'CompanyName'
          Size = 40
        end
      end
      object BindingsList1: TBindingsList
        Methods = <>
        OutputConverters = <>
        Left = 20
        Top = 5
        object LinkPropertyToFieldText: TLinkPropertyToField
          Category = 'Quick Bindings'
          DataSource = bsCustomer
          FieldName = 'CustomerNo'
          ComponentProperty = 'Text'
        end
        object LinkPropertyToFieldText2: TLinkPropertyToField
          Category = 'Quick Bindings'
          DataSource = bsCustomer
          FieldName = 'CompanyName'
          ComponentProperty = 'Text'
        end
        object LinkPropertyToFieldText3: TLinkPropertyToField
          Category = 'Quick Bindings'
          DataSource = bsCustomer
          FieldName = 'CustomerNo'
          ComponentProperty = 'Text'
        end
        object LinkPropertyToFieldText4: TLinkPropertyToField
          Category = 'Quick Bindings'
          DataSource = bsCustomer
          FieldName = 'CompanyName'
          ComponentProperty = 'Text'
        end
        object LinkPropertyToFieldText5: TLinkPropertyToField
          Category = 'Quick Bindings'
          DataSource = bsCustomer
          FieldName = 'CustomerNo'
          ComponentProperty = 'Text'
        end
        object LinkPropertyToFieldText6: TLinkPropertyToField
          Category = 'Quick Bindings'
          DataSource = bsCustomer
          FieldName = 'CompanyName'
          ComponentProperty = 'Text'
        end
        object LinkPropertyToFieldText7: TLinkPropertyToField
          Category = 'Quick Bindings'
          DataSource = bsCustomer
          FieldName = 'CustomerNo'
          Component = Label1
          ComponentProperty = 'Text'
        end
        object LinkPropertyToFieldText8: TLinkPropertyToField
          Category = 'Quick Bindings'
          DataSource = bsCustomer
          FieldName = 'CompanyName'
          Component = Label2
          ComponentProperty = 'Text'
        end
      end
    end
    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk