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

[Solved] Custom aggregates for Dynamic columns

4 Answers 260 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Suresh K
Top achievements
Rank 1
Suresh K asked on 30 Dec 2009, 01:02 PM
hi.
I have Grid Like This.
<telerik:RadGrid ID="RadGridLineCount" runat="server" GridLines="None" AllowPaging="True" HeaderStyle-HorizontalAlign="Right" 
                Skin="Office2007" PageSize="20" ShowFooter="True"
                <MasterTableView> 
                    <ExpandCollapseColumn Visible="True"
                    </ExpandCollapseColumn> 
                    <DetailTables> 
                        <telerik:GridTableView Name="UserPrivilage" DataKeyNames="pvgid" ClientDataKeyNames="pvgid" 
                            runat="server">                            
                            <ExpandCollapseColumn Visible="True"
                            </ExpandCollapseColumn> 
                            <DetailTables> 
                                <telerik:GridTableView Name="Clients" DataKeyNames="clientid" runat="server"
                                    <ExpandCollapseColumn Visible="True"
                                    </ExpandCollapseColumn> 
                                    <DetailTables> 
                                        <telerik:GridTableView Name="Accounts" DataKeyNames="accountid" runat="server"
                                            <ExpandCollapseColumn Visible="True"
                                            </ExpandCollapseColumn> 
                                            <DetailTables> 
                                                <telerik:GridTableView Name="Providers" DataKeyNames="providerid" ClientDataKeyNames="providerid" 
                                                    runat="server"
                                                </telerik:GridTableView> 
                                            </DetailTables> 
                                        </telerik:GridTableView> 
                                    </DetailTables> 
                                </telerik:GridTableView> 
                            </DetailTables> 
                        </telerik:GridTableView> 
                    </DetailTables> 
                </MasterTableView> 
                <ClientSettings EnableRowHoverStyle="True"
                    <Selecting AllowRowSelect="True" /> 
                    <ClientEvents OnRowContextMenu="RowContextMenu" /> 
                </ClientSettings> 
                <HeaderStyle HorizontalAlign="Right" /> 
            </telerik:RadGrid> 
here i want the custom aggregate for all the Columns.
initially i don't know the column name.
can any one help me how to do the aggregate to All Dynamic Columns.
and i want only the data type = Integer columns not for string columns.here i have one string data type column.

Thank You.
Suresh K.

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Dec 2009, 02:27 PM
Hello Suresh,

You can check for the DataType of the columns as shown below:
c#:
protected void RadGrid1_CustomAggregate(object sender, GridCustomAggregateEventArgs e) 
    { 
        if ((e.Column as GridBoundColumn).DataType ==  typeof(System.Int32) ) 
        { 
           //your code to calculate the aggregate 
        } 
    } 

Hope this helps..
Princy.
0
Suresh K
Top achievements
Rank 1
answered on 31 Dec 2009, 07:00 AM
hi Princy.
Thanks for your response.
i tried this code.
but it's not going to this "RadGrid1_CustomAggregate" event
 can u tell me how to do this.

Thank You.
Suresh K.
0
Princy
Top achievements
Rank 2
answered on 31 Dec 2009, 07:54 AM
Hello Suresh,

Make sure if you have attached the event handler for the grid in the aspx and also if you have set the Aggregate property for the dynamic column as shown below:
aspx:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" ShowFooter="true" AutoGenerateColumns="false" runat="server"  
OnCustomAggregate="RadGrid1_CustomAggregate"

c#:
protected void Page_Load(object sender, EventArgs e)   
 if(!IsPostBack) 
 { 
   GridBoundColumn col1 = new GridBoundColumn(); 
   col1.DataField = "Number"
   col1.HeaderText = "Number"
   col1.UniqueName = "Number"
   col1.Aggregate = GridAggregateFunction.Custom; 
   col1.DataType = System.Type.GetType("System.Int32"); 
   RadGrid1.Columns.Add(col1); 
 } 
}  

Happy New Year :)
Princy.
0
Suresh K
Top achievements
Rank 1
answered on 31 Dec 2009, 10:39 AM
hi princy
Thanks for your response.
here i am able to firing the event.
can u please  tell me how to do the codeing for Total to all the Dynamic columns.
here initially i don't know the column names.
you can see the sample print screen below


Happy New Year :)



Suresh K
Tags
Grid
Asked by
Suresh K
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Suresh K
Top achievements
Rank 1
Share this question
or