Created
April 3, 2015 07:02
-
-
Save anonymous/204ca4a8332feac6c915 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object frmMain: TfrmMain | |
Left = 0 | |
Top = 0 | |
BorderStyle = bsSizeToolWin | |
Caption = 'Expand example.' | |
ClientHeight = 295 | |
ClientWidth = 136 | |
Color = clBtnFace | |
Font.Charset = DEFAULT_CHARSET | |
Font.Color = clWindowText | |
Font.Height = -11 | |
Font.Name = 'Tahoma' | |
Font.Style = [] | |
OldCreateOrder = False | |
OnCreate = FormCreate | |
PixelsPerInch = 96 | |
TextHeight = 13 | |
object grdMain: TcxGrid | |
Left = 0 | |
Top = 0 | |
Width = 136 | |
Height = 252 | |
Align = alClient | |
TabOrder = 0 | |
object tbvMain: TcxGridTableView | |
NavigatorButtons.ConfirmDelete = False | |
DataController.Summary.DefaultGroupSummaryItems = <> | |
DataController.Summary.FooterSummaryItems = <> | |
DataController.Summary.SummaryGroups = <> | |
object clmYear: TcxGridColumn | |
Caption = 'Year' | |
end | |
object clmPopulation: TcxGridColumn | |
Caption = 'Population' | |
end | |
end | |
object lvlMain: TcxGridLevel | |
GridView = tbvMain | |
end | |
end | |
object pnlExpand: TPanel | |
Left = 0 | |
Top = 252 | |
Width = 136 | |
Height = 43 | |
Align = alBottom | |
TabOrder = 1 | |
object btnExpand: TButton | |
Left = 8 | |
Top = 6 | |
Width = 121 | |
Height = 25 | |
Caption = 'Expand by year = 1' | |
TabOrder = 0 | |
OnClick = btnExpandClick | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit uMain; | |
interface | |
uses | |
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | |
Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters, | |
cxStyles, dxSkinsCore, dxSkinscxPCPainter, cxCustomData, cxFilter, cxData, | |
cxDataStorage, cxEdit, cxGridCustomTableView, cxGridTableView, | |
cxGridCustomView, cxClasses, cxGridLevel, cxGrid, StdCtrls, ExtCtrls; | |
type | |
TfrmMain = class(TForm) | |
grdMain: TcxGrid; | |
lvlMain: TcxGridLevel; | |
tbvMain: TcxGridTableView; | |
clmYear: TcxGridColumn; | |
clmPopulation: TcxGridColumn; | |
pnlExpand: TPanel; | |
btnExpand: TButton; | |
procedure FormCreate(Sender: TObject); | |
procedure btnExpandClick(Sender: TObject); | |
private | |
{ Private declarations } | |
public | |
{ Public declarations } | |
end; | |
var | |
frmMain: TfrmMain; | |
implementation | |
{$R *.dfm} | |
procedure TfrmMain.btnExpandClick(Sender: TObject); | |
const | |
CurrentYear = 1; | |
var | |
i: Integer; | |
begin | |
for i := 0 to tbvMain.ViewData.RowCount - 1 do | |
begin | |
if not tbvMain.ViewData.Rows[i].IsData then | |
begin | |
if tbvMain.ViewData.Rows[i].Values[clmYear.Index] = CurrentYear then | |
tbvMain.ViewData.Rows[i].Expand(False); | |
end; | |
end; | |
end; | |
procedure TfrmMain.FormCreate(Sender: TObject); | |
var | |
i: Integer; | |
begin | |
// Prepare some random data. | |
Randomize; | |
tbvMain.DataController.RecordCount := 10; | |
for i := 0 to tbvMain.DataController.RecordCount - 1 do | |
begin | |
tbvMain.DataController.Values[i, clmYear.Index] := Random(3) + 1; | |
tbvMain.DataController.Values[i, clmPopulation.Index] := Random(100); | |
end; | |
end; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment