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 ?