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

How to show the total number of record in footer?

7 Answers 1022 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff Tang
Top achievements
Rank 1
Jeff Tang asked on 24 Oct 2008, 06:24 AM
How to show the total number of record in footer? I have no paging. Thanls

7 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Oct 2008, 06:51 AM
Hello Jeff,

You can set Aggregate property for bound columns as 'Count' which will be dispalyed in the footer.For more information on this check out the link below
Aggregates

Thanks
Princy.
0
Jeff Tang
Top achievements
Rank 1
answered on 24 Oct 2008, 07:02 AM
Thanks, I got the total number? It displayed " Count : xxx" , can I change the display to my custom text, (eg. "No. of Records : xxx") ? Thanks.
0
Shinu
Top achievements
Rank 2
answered on 24 Oct 2008, 07:21 AM
Hi Jeff,

Try out the following code snippet to achieve the desired scenario.

CS:
   protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridFooterItem) 
        { 
            GridFooterItem footer = (GridFooterItem)e.Item; 
            string strCount = footer["columnUniqueName"].Text.Split(':')[1]; 
            footer["columnUniqueName"].Text = "No. of Records :" + strCount; 
        } 
    } 


Hope this helps..
Shinu
0
Jeff Tang
Top achievements
Rank 1
answered on 24 Oct 2008, 07:32 AM
Thanks. But when should I call this function?
0
Shinu
Top achievements
Rank 2
answered on 24 Oct 2008, 09:29 AM
Hi Jeff,

You can try the code snippet in the ItemDataBound event of the Grid as shown above.

Shinu
0
Daniel
Telerik team
answered on 24 Oct 2008, 09:45 AM
Hello Jeff,

RadGrid1_ItemDataBound event handler will be called automatically by your RadGrid control if attached either declaratively or in code-behind.

declarative:
<telerik:RadGrid ID="RadGrid1" runat="server" OnItemDataBound="RadGrid1_ItemDataBound" 
... 

in code-behind (C#):
RadGrid1.ItemDataBound += new Telerik.Web.UI.GridItemEventHandler(RadGrid1_ItemDataBound); 




Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Rob
Top achievements
Rank 1
answered on 18 Dec 2008, 04:58 PM
I've implemented the code above to replace the string "Custom :" that RadGrid is putting in my footer when I custom aggregate a bound column that contains text.

I'm struggling to understand why the grid is inserting the string "Custom :" at all though. It's definitely not a string that I'm putting in there. Furthermore, if I provide a value for this column in the CustomAggregate event, for example "$ Totals", then this is concatenated to the "Custom :" string, and I end up with "Custom : $ Totals"! 

Fortunately, replacing the footer text for this column in the ItemDataBound event as per the code in the post above works, but why is the grid inserting this string "Custom :" into my footer cell?! Surely the whole point to custom aggregation is that I decide what goes in each cell, not the grid.
Tags
Grid
Asked by
Jeff Tang
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jeff Tang
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Daniel
Telerik team
Rob
Top achievements
Rank 1
Share this question
or