How can create summary footer on runtime?

只谈情不闲聊 提交于 2019-12-08 07:58:05

问题


I use TcxGrid I have create fields on execution time because I have a pivot query and columns are variable

I filled my grid like theese codes

grdCevapDBTableView2.BeginUpdate;
grdCevapDBTableView2.ClearItems;
fillGridView(grdCevapDBTableView2,command);
grdCevapDBTableView2.DataController.CreateAllItems;
grdCevapDBTableView2.EndUpdate;

Now I want to get sum values from these columns. How can create summary footer on runtime?


回答1:


Say for example you had a field called cost and you wanted to summarise the total:

index := grdCevapDBTableView2.GetColumnByFieldName('cost').index;
grdCevapDBTableView2.Columns[index].Summary.Footerkind:=skSum;
grdCevapDBTableView2.Columns[index].Summary.FooterFormat:='£ #.##';

I would also stick the beginupdate and endupdate between try..finally block, ie:

grdCevapDBTableView2.BeginUpdate;
try       
  grdCevapDBTableView2.ClearItems;       
  fillGridView(grdCevapDBTableView2,command);       
  grdCevapDBTableView2.DataController.CreateAllItems;       
finally
  grdCevapDBTableView2.EndUpdate;   
end;

this just ensures that your tableview will eventually end the update and redraw.



来源:https://stackoverflow.com/questions/2514190/how-can-create-summary-footer-on-runtime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!