0

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.

user763539
  • 3,509
  • 6
  • 44
  • 103
  • Can't test it as I have no access to *DevExpress* currently, but I think there was the possibility to do this by expanding the selected record detail. Something like `cxGrid1DBTableView1.ViewData.Records[i].Expand(true)`. – Guillem Vicens May 06 '15 at 07:54
  • Locate returns a Boolean value. Returns False if the record is not found (aka your date). So if it returns False, show your message – Jason May 06 '15 at 23:20

1 Answers1

0

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;
user763539
  • 3,509
  • 6
  • 44
  • 103