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

[Solved] Time Calculation in Rad Grid

2 Answers 225 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 04 Nov 2009, 01:49 PM
hi.

I have a grid like this with GridCalculatedColumn DataType="System.TimeSpan".
Now I want to Calculate The Total Time.
Can Any one help me how to calculate the Total Time With GridCalculatedColumn .



<telerik:RadGrid ID="MReportRGrid" runat="server" AllowFilteringByColumn="True" AllowPaging="True" 
                        GridLines="None" PageSize="20" ShowGroupPanel="True" Skin="Sunset" Style="position: static" 
                        Visible="False" AutoGenerateColumns="False" ShowFooter="true"
                        <MasterTableView ShowGroupFooter="true" AllowMultiColumnSorting="true"
                            <Columns> 
                                <telerik:GridBoundColumn Aggregate="Count" DataField="Account" HeaderText="Account" 
                                    UniqueName="Account" FooterText="Total Files:"
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="ProviderName" HeaderText="Provider Name" UniqueName="ProviderName"
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="location" HeaderText="Location" UniqueName="location"
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="sublocation" HeaderText="Sub Location" UniqueName="sublocation"
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="BatchTime" HeaderText="Batch Time" UniqueName="BatchTime"
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="serialno" HeaderText="Serial #" UniqueName="serialno"
                                </telerik:GridBoundColumn> 
                              
                                <telerik:GridCalculatedColumn DataFields="playlength" HeaderText="Play Length" UniqueName="playlength" 
                                    DataType="System.TimeSpan" FooterText="Total Play Length:" Aggregate="sum"
                                </telerik:GridCalculatedColumn> 
                            </Columns> 
                            <GroupByExpressions> 
                                <telerik:GridGroupByExpression> 
                                    <SelectFields> 
                                        <telerik:GridGroupByField FieldAlias="ProviderName" FieldName="ProviderName" FormatString="{0:D}" 
                                            HeaderValueSeparator=" From: " HeaderText="Provider Name" /> 
                                             
                                    </SelectFields> 
                                    <GroupByFields> 
                                        <telerik:GridGroupByField FieldAlias="ProviderName" FieldName="ProviderName" SortOrder="Descending" 
                                            FormatString="{0:D}" HeaderText="Provider Name" /> 
                                    </GroupByFields>                                     
                                </telerik:GridGroupByExpression> 
                            </GroupByExpressions> 
                            <RowIndicatorColumn> 
                                <HeaderStyle HorizontalAlign="Center" /> 
                                <ItemStyle HorizontalAlign="Center" /> 
                            </RowIndicatorColumn> 
                        </MasterTableView> 
                        <ClientSettings AllowDragToGroup="True"
                        </ClientSettings> 
                    </telerik:RadGrid> 

Thank You
Suresh K

2 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 09 Nov 2009, 08:39 AM
Hi Suresh,

Basically, there is no default function exposed, to handle a TimeSpan by default. However, you can use a custom aggregate, to handle this. Setting Aggregate="Custom" will cause the CustomAggregate function to be raised. There, you can calculate the result for the footer. For the items, you can calculate the value manually, by accessing the cell values, and calculating the time span.
I hope this suggestion helps.

All the best,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Suresh K
Top achievements
Rank 1
answered on 10 Nov 2009, 10:30 AM
Hi.
Thanks For your Response.
i did this In some other way.
that is First i converted Time stamp to secondes and stored in one column.
Then In dataBound Event I converted seconds into Time Stamp.
Now its working Properly.
Tags
Grid
Asked by
Suresh K
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Suresh K
Top achievements
Rank 1
Share this question
or