Total a COLUMN on column click

2 posts, 0 answers
    KIRAN RAJ avatar
    23 posts
    Member since:
    Sep 2011

    Posted 15 Dec 2011 Link to this post

    Hi guys,

    I am stucked..I m looking for code which can Total a column on a event like "column  click" .. I was able to get footer total 

     protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
                 GridFooterItem footerItem = (GridFooterItem)e.Item;
                var total =Convert.ToInt64(objbal.ExecuteStringQuery( "select TTotal from  TAB1"));
                footerItem["Total  Capacity"].Text = "Total   Capacity: " + total.ToString() ;

    i WANT TO DISPLAY COLUMN total on clicking header column  on grid.. Any sol..plzz..?
  2. Casey
    Casey avatar
    299 posts
    Member since:
    Jul 2009

    Posted 15 Dec 2011 Link to this post

    Since this is posted in the Ajax forum, I'm assuming that you want this done via ajax, or client side, right?

    There is a client event for a column click: ClientEvent-OnColumnClicked. I was able to set the footer text for the clicked column by using this event, and initiating an ajax request. 

    Here is the relevant code:
    Add this to your RadGrid:
    <ClientSettings  ClientEvents-OnColumnClick="colClick">

    Make sure your RadAjaxManager definition allows RadGrid1 to update RadAjaxManager1 and that RadAjaxManager1 can update RadGrid1:
    <telerik:RadAjaxManager ID="RadAjaxManager1" EnableAJAX="true" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                    <telerik:AjaxUpdatedControl ControlID="RadAjaxManager1" />
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <telerik:AjaxUpdatedControl ControlID="RadAjaxManager1" />

    JavaScript to initiate ajax request:
    function colClick(sender, eventArgs) {
        var col = eventArgs.get_gridColumn();
        if (col != null) {
            var ajaxMan = $find("<%= RadAjaxManager1.ClientID %>");
            if (ajaxMan != null) {

    OnAjaxRequest Code (I think you could get rid of the first line of code here and just use "fItm[e.Argument].Text" instead of "fItm[col.UniqueName].Text"):
    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
            GridColumn col = RadGrid1.MasterTableView.GetColumn(e.Argument);
            GridFooterItem fItm = RadGrid1.MasterTableView.GetItems(GridItemType.Footer)[0] as GridFooterItem;
            fItm[col.UniqueName].Text = "HERE IS THE TOTAL!!!";

    I hope this helps!
Back to Top