0

When showing or hiding a column (in code) in the cxGrid that has a footer implemented (SUM),it does not refresh its value.

How do you refresh the footer in code ?

Using this :

procedure TForm1.cxGrid2DBTableView1CustomDrawFooterCell(
Sender: TcxGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridColumnHeaderViewInfo; var ADone: Boolean);
begin
cxgrid2DBTableView1.DataController.Summary.Recalculate;
end;

...makes all the other devexpress components on the form fail to repaint properly.Cant see a thing....

edit : To show or hide the field in the grid I use :

    procedure TForm1.cxCheckBox1Click(Sender: TObject);
    var
    C:TcxGridDBColumn;
    begin
    C := cxGrid1DBTableView1.GetColumnByFieldName('PP');
    if Assigned(C) then C.Visible := not C.Visible;
    begin
          absquery2.Edit;
          absquery2.FieldByName('PP').AsCurrency := 15 * ABSQuery2.FieldByName('days').asInteger;
          if C.Visible then  begin
          ABSQuery2.FieldByName('total').asCurrency := (ABSQuery2.FieldByName('total').AsCurrency) + (ABSQuery2.FieldByName('PP').AsCurrency) ;
          end else begin
          ABSQuery2.FieldByName('total').asCurrency := (ABSQuery2.FieldByName('total').AsCurrency) - (ABSQuery2.FieldByName('PP').AsCurrency);
          ABSQuery2.Post;
          ABSQuery2.Refresh;
          end;

end;
end;

On calculate fields of the query I have :

procedure TForm1.ABSQuery2CalcFields(DataSet: TDataSet);
begin
case cxradiogroup1.ItemIndex of
0: begin
absquery2.FieldByName('tt').value := 1.30;
if (absquery2.FieldByName('room_type').asstring = 'SGL') then begin
absquery2.FieldByName('TTS').value := absquery2.FieldByName('days').value * 1.30;
absquery2.FieldByName('OSEB').value :='1';
end else begin
absquery2.FieldByName('TTS').value := (absquery2.FieldByName('days').value) * (absquery2.FieldByName('tt').value * 2);
absquery2.FieldByName('OSEB').value :='2';
end;
absquery2.FieldByName('total').value := absquery2.FieldByName('days').value * absquery2.FieldByName('rate_price').value + absquery2.FieldByName('TTS').value;
absquery2.FieldByName('POND').value := absquery2.FieldByName('RATE_PRICE').value / absquery2.FieldByName('OSEB').value;
end;
.....

This all seems to be working except the footer that wont accept che change in the grids total value. It seems to me that the grids footer accepts only the oncalculate fields event and not showing or hiding the field.How can I make this work ?

user3777264
  • 72
  • 1
  • 9
  • There is no enough information. Is it a Db table. I think you can recalculate the footer like .DataController.Summary.Recalculate (not tested) – Ravaut123 Dec 30 '14 at 07:33
  • There must be something else at hand here. I just tried to populate an `unbound view` with some random data in an invisible column and then made it visible. Summary was always correctly recalculated and shown. We will need a [SSCCE](http://sscce.org/) to be able to help you. – Guillem Vicens Dec 30 '14 at 09:55
  • Yes,its a temp db table. – user3777264 Dec 30 '14 at 11:20
  • Also tried it with a `bound view` attached to a `TFDMemTable`. I still can see the summary correctly updated everytime. Please create an SSCCE to reproduce ypur error. I made my tests on `Delphi XE5` with `devExpress 13.2.3`. – Guillem Vicens Dec 30 '14 at 14:39
  • The field "Total" (the one with the footer) is a simple calculated field. All the calculations display correctly. However adding a new field with a new value is supposed to do some additional calculation resulting in "total" field change. In the grid, this new change is evident and works. However the footer does not change the old value.In the grid the new total is displayed ok while the footer that is supposed to reflect the change,does not. I am using delphi xe7 with DE 14.1.3. – user3777264 Dec 30 '14 at 19:01
  • You did not mention before _Total_ was a calculated field. Anyway, tested it again with a calculated field and adding records (as I understand you are doing) and it still works. In any case, please provide the code to reproduce this or we won't be able to help you. – Guillem Vicens Dec 31 '14 at 09:17

0 Answers0