user763539
user763539

Reputation: 3719

cxgrid expand grouped data using cxDateEdit

My displayed data in the cxGrid is grouped by date (collapsed) . Is there a way I can expand this grouped data "only" for a selected date using cxDateEdit for the occasion ?

Right now,all I could manage is to collapes or expand all data using buttons:

procedure TArchive.EXPANDClick(Sender: TObject);
begin
cxGrid1DBTableView1.ViewData.Expand(True);
end;


procedure TArchive.COLLAPSEClick(Sender: TObject);
begin
cxGrid1DBTableView1.ViewData.Collapse(True);
end;

I would like to expand the records only for the date displayed in the cxDateEdit. And possibly display a message if no data for the desired date was found.

Edit : I have found a way to do this :

procedure TARCHIVE.cxDateEdit1PropertiesChange(Sender: TObject);
begin
with cxGrid1DBTableView1 do
  begin
    DataController.DataSource.DataSet.Locate('FOR_DATE',cxDateEdit1.Date,
    [loPartialKey]);
    ViewData.Records[DataController.FocusedRowIndex].Expand(True);
end;
end;

However I cant figure out how to flash a message if the date displayed in the cdDateEdit does not exist in the cxGrid.

Upvotes: 0

Views: 1561

Answers (1)

user763539
user763539

Reputation: 3719

Got it :

    procedure TARCHIVE.cxDateEdit1PropertiesChange(Sender: TObject);
    begin
    with cxGrid1DBTableView1 do
    begin
    if   DataController.DataSource.DataSet.Locate('FOR_DATE',cxDateEdit1.Date,
        [loPartialKey]) then begin
        ViewData.Records[DataController.FocusedRowIndex].Expand(True);
    end else begin
    ShowMessage('No entries for desired date.');
    end;
    end;
    end;

Upvotes: 0

Related Questions