I'm trying to override the footer of a column to enter in a grand total. The grid is grouped by a column and I want to be able to plug in a grand total under the final group total. I have seen some posts/documentation on creating mutliple rows in the footer, but it involves javascript and knowing the index of the columns you want totaled. I was hoping to resolve this through code behind. I can get it to work, but it adds a "Grand Total" line for all group totals. I only want it to add it to the last one. I have code snippets below.. How can I get a handle to the column footer in the last group total to be able to add in a grand total? The columns in the grid can change, so the index of the column to be totaled is always changing. What's not changing is the datakey name of the column. Thanks in advance!!
<igtbl:UltraGridColumn Width="110px" IsBound="false" Format="$###,###.00" Key="mCostBasisWReInvest" BaseColumnName="mCostBasisWReInvest" HeaderText="Total Cost" DataType="Double">
<HeaderStyle HorizontalAlign="Right" Wrap="true" />
<Footer Total="Sum"></Footer>
</igtbl:UltraGridColumn>
_nfsRunningRowCount += e.Rows.Count
If _nfsRunningRowCount = _nfsRowCount Then
End If
End Sub
Hello pmdaniel99,
Miss read your post. I would recommend creating a hierarchical structure; each band will have its own total, effectively giving you sub and grand totals.
Patrick
Patrick - Thanks for the post! I currently only have 1 band as I did not see the need to create more. I thought they would be used when you want to see additional detail for a given row. I have all the detail and it's grouped by the column I need for sub totals. How would I implement the new band to handle the grand totals and group totals?
Much appreciation for the time!
That's exactly what I had done intially. I had placed the grand total in a label outside the grid. The only issue with that was when the grid scrolled (which it has to horizontally), the grand total did not scroll with it. I keep investigating/searching for a solution within the InitializeFooter function. I am able ot get a handle to the last row, but can't for the footer. The code below updates all footers, not just the last one. You would think I could grab the instance of the last footer row in there... Maybe I need to start looking into the group section rows. Perhaps there is something in there I'm missing.. Thanks again Patrick for your time and assistance.
e.Rows(rowIndex).Band.Columns.FromKey("mCostBasisWReInvest").Footer.Caption
That all depends on the structure of your data. With the limited information supplied it is impossible to determine if that will help or not. However now that I think about it, if you apply grouping to the data and you have a column footer displaying a total, the total should update after grouping has been applied. In other words, each group would have a different footer total displayed which is the total of the group. So, if no grouping is applied you would see the grand total in the footer and if grouping is applied you would see totals for the group displayed. I have an application that exhibits this behavior. The only problem is that you would have to display the grand total, perhaps in a label below the grid, when grouping is applied.
Good luck,