Question

How can I hide a row in cxGrid unbound mode?

It's been hours already and I can't figure it out. I googled it and failed.

Was it helpful?

Solution

I just created a sample app with a grid in unbound mode and used the OnFilterRecord as suggested by DevExpress in its recommendation, and it works fine.

Following you can see my test code:

type
  TForm1 = class(TForm)
    testLevel: TcxGridLevel;
    testGrid: TcxGrid;
    testView: TcxGridTableView;
    testViewColumn1: TcxGridColumn;
    testViewColumn2: TcxGridColumn;
    procedure FormCreate(Sender: TObject);
    procedure tviewDataControllerFilterRecord(
      ADataController: TcxCustomDataController; ARecordIndex: Integer;
      var Accept: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  testView.DataController.RecordCount := testView.DataController.RecordCount + 1;
  testView.DataController.Values[testView.DataController.RecordCount - 1,0] := 'foo';
  testView.DataController.Values[testView.DataController.RecordCount - 1,1] := 'bar';

  testView.DataController.RecordCount := testView.DataController.RecordCount + 1;
  testView.DataController.Values[testView.DataController.RecordCount - 1,0] := 'foo2';
  testView.DataController.Values[testView.DataController.RecordCount - 1,1] := 'bar2';
end;

procedure TForm1.tviewDataControllerFilterRecord(
  ADataController: TcxCustomDataController; ARecordIndex: Integer;
  var Accept: Boolean);
begin
  Accept := (testView.DataController.Values[ARecordIndex,0] <> 'foo');
end;

And the result:

hiding row in unbound cxGrid

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top