We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Totals at bottom of Grid?

Hi I have a data bound grid which has 2 columns which holds financial amounts. What I would like to do is have the last row to hold the total of these columns. Anybody have any idea on how to do this? Mac

6 Replies

TB Thomas Brix Lyng January 30, 2003 10:19 AM UTC

Hi Mac I have just found this solution and it works for me. Try it out. You can pick up the link for the solution in the attached .zip document. regards Thomas > Hi > > I have a data bound grid which has 2 columns which holds financial amounts. > > What I would like to do is have the last row to hold the total of these columns. > > Anybody have any idea on how to do this? > > Mac > >


AD Administrator Syncfusion Team January 30, 2003 10:34 AM UTC

One way you could try to do this is to add a unbound row at the top of your datagrid, and set the formula cells into this unbound row. The GDBGMultiHeader sample shows how you might add this extra header row whose information is stored in the grid's data object (and not in your datatable). But this puts the totals at the top. If you want them at the bottom, its more work. What you could do is hide this extra top row, and add a virtual GridControl docked under the GriddataBoundGrid that just displays the values from this hidden row. Attached is a try at doing this. It uses a panel to hold the 2 grids, and positions the grids on the panel so the gridcontrol is exactly under the GridDataBoundGrid. It also makes sure the panel is sized so a whole number of rows are visible so things look OK. If you want to allow the user's to scroll horizontally, then there is more work. You would need to add Windows Forms scrollbars to the panel, and use those scroll bars to scroll the GriddataBoundGrid. The ScrollBars sample that ships with the products steps you through this task.


AD Administrator Syncfusion Team January 31, 2003 01:29 PM UTC

Clay, What you mentioned in the above post can be done. But it takes too much of effort everytime we need something like this. This is a feature request. What we need is a "Summary row" in the GridControlBase at the bottom of the grid. The summary row will contain the same number of columns as the grid. But what needs to be displayed in each cell can be specified by the programmer using an event. E.g.: Totals of the column, Avg. of the column, number of rows in that column that have value > 1000 etc. "Summary Row" should be visible all the time even when the control is scolled vertically (just like column header, but at the bottom), so that the user can see the totals anytime the values are changed. thanks, - Reddy


SW Sean Wilkins September 15, 2003 04:37 PM UTC

Would you happen to have a VB.Net version of this that you could intorduce to the forum? Thanks! > One way you could try to do this is to add a unbound row at the top of your datagrid, and set the formula cells into this unbound row. The GDBGMultiHeader sample shows how you might add this extra header row whose information is stored in the grid's data object (and not in your datatable). > > But this puts the totals at the top. If you want them at the bottom, its more work. What you could do is hide this extra top row, and add a virtual GridControl docked under the GriddataBoundGrid that just displays the values from this hidden row. > > Attached is a try at doing this. It uses a panel to hold the 2 grids, and positions the grids on the panel so the gridcontrol is exactly under the GridDataBoundGrid. It also makes sure the panel is sized so a whole number of rows are visible so things look OK. > > If you want to allow the user's to scroll horizontally, then there is more work. You would need to add Windows Forms scrollbars to the panel, and use those scroll bars to scroll the GriddataBoundGrid. The ScrollBars sample that ships with the products steps you through this task.


SW Sean Wilkins September 15, 2003 04:46 PM UTC

Would you happen to have a VB.Net version of this that you could intorduce to the forum?


AD Administrator Syncfusion Team September 16, 2003 05:47 AM UTC

In our 2.0 release, the new grouping support will support summary rows directly without the work that was done to get the above sample to work. Beta version of this code base should be available in the next week or so. I will try to post a VB version of this sample later this week. But I think it needs to be reworked to support the 1.6.1.x code base.

Loader.
Live Chat Icon For mobile
Up arrow icon