This is a migrated thread and some comments may be shown as answers.

Trying to get sums in footer

4 Answers 50 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rusty
Top achievements
Rank 1
Rusty asked on 31 Jan 2012, 08:16 PM
OK, here is what I am trying to do. I have a grid and the customer wants totals at the bottom.  Here is an example of the columns in the grid.
<telerik:GridBoundColumn DataField="RulesIdentifiedCount" HeaderText="Rules Identified" Visible="true"                                    UniqueName="RulesIdentifiedCount">
</telerik:GridBoundColumn>
Here is an the code from the itemdatabound event.


Dim

 

 

rulesidentified As Integer = 0

 

If dtr.Read() Then
gridItem("RulesIdentifiedCount").Text = dtr("RulesIdentifiedCount")
rulesidentified = rulesidentified = dtr("RulesIdentifiedCount")
End If

At the end I am taking the rulesidentified variable and trying to set the footer.
If (TypeOf e.Item Is GridFooterItem) Then
Dim footerItem As GridFooterItem = CType(e.Item, GridFooterItem)
footerItem("RulesApplicableCount").Text = rulesidentified
End If


I am not getting the footer to show anything.  What am I doing wrong?

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 01 Feb 2012, 05:07 AM
Hello,

Make sure you set ShowFooter as true in RadGrid. Also take a look into the following documentation for more.
Totals in Grid Footers

Thanks,
Princy.
0
Rusty
Top achievements
Rank 1
answered on 01 Feb 2012, 02:22 PM
I am sorry I didn't include the radgrid code but showfooter = true already. I just can even get something to show although it was a hard coded value with I converted the column to a template.
0
Vasil
Telerik team
answered on 01 Feb 2012, 04:39 PM
Hi Rusty,

Did you tried the approach provided in the help topic that Princy suggested. I believe it explains in enough details how to show totals. You could also check this demo about the same topic.

Set a debugger in your project and make sure that the Grid's DataBound is actually handled and that your code at footerItem("RulesApplicableCount").Text = rulesidentified is really executed. If the total is not shown in the footer, most probably the text was never set for some reason. We could not say this only by the code snippet that you have included. You need to debug it and confirm that the code executes correctly.

Kind regards,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Richard
Top achievements
Rank 1
answered on 01 Feb 2012, 05:30 PM
Rusty:

I'm not sure if this is the cause for the "no show" value, but it looks like you've defined rulesidentified As Integer = 0 and then you're attempting to apply it without casting to a string:
footerItem("RulesApplicableCount").Text = rulesidentified

Demo code from Totals in Grid Footers documentation page:
Dim total As Integer
Private Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs)
    If (TypeOf e.Item Is GridDataItem) Then
        Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)
        Dim fieldValue As Integer = Integer.Parse(dataItem("Quantity").Text)
        total = (total + fieldValue)
    End If
    If (TypeOf e.Item Is GridFooterItem) Then
        Dim footerItem As GridFooterItem = CType(e.Item, GridFooterItem)
        footerItem("Quantity").Text = "total: " + total.ToString()
    End If
End Sub

Hope this helps!
Tags
Grid
Asked by
Rusty
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Rusty
Top achievements
Rank 1
Vasil
Telerik team
Richard
Top achievements
Rank 1
Share this question
or