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

Calculating sum of a column in child grid and displaying it as seperate column in parent grid

3 Answers 142 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Emaad
Top achievements
Rank 1
Emaad asked on 07 Jul 2015, 02:52 PM

Hello,

I am a novice programmer and I have come to a standstill of how to proceed next. Please find my grid .aspx code below:

 

<telerik:RadGrid ID="RadGrid1" runat="server" ShowStatusBar="true" AutoGenerateColumns="False" Skin="MetroTouch" CssClass="RadGrid_ModernBrowsers"
            PageSize="30" AllowSorting="True" AllowMultiRowSelection="False" AllowPaging="True" OnItemDataBound="RadGrid1_ItemDataBound"
            AllowFilteringByColumn="True" ShowGroupPanel="true" CanRetrieveAllData ="False"
            OnDetailTableDataBind="RadGrid1_DetailTableDataBind" OnNeedDataSource="RadGrid1_NeedDataSource">
            <PagerStyle Mode="NextPrevAndNumeric" />
            <GroupingSettings CaseSensitive="false" />
            <MasterTableView DataKeyNames="DBName, ConfigName, TransactionGUID" AllowMultiColumnSorting="False" Font-Size ="9" HeaderStyle-Font-Bold="true">                
                        <DetailTables>
                            <telerik:GridTableView DataKeyNames="DBName1, ConfigName1, SectionName1, TransactionGUID1" Name="SectionDetails" Width="100%" Font-Size ="9">
                                <Columns>
                                    <telerik:GridBoundColumn SortExpression="SectionName1" HeaderText="Section Name" HeaderButtonType="TextButton"
                                        DataField="SectionName1" AutoPostBackOnFilter="true" CurrentFilterFunction="contains" ShowFilterIcon="false" >
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn SortExpression="RejectedLines1" HeaderText="Rejected Lines" HeaderButtonType="TextButton"
                                        DataField="RejectedLines1" AutoPostBackOnFilter="true" CurrentFilterFunction="contains" ShowFilterIcon="false" >
                                    </telerik:GridBoundColumn>
                                   </Columns>
                            </telerik:GridTableView>
                        </DetailTables>                              
                <Columns>
                    <telerik:GridBoundColumn SortExpression="DBName" HeaderText="DB Name" HeaderButtonType="TextButton"
                        DataField="DBName" AutoPostBackOnFilter="true" CurrentFilterFunction="contains" ShowFilterIcon="false" >
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="DateTime" HeaderText="Date & Time" HeaderButtonType="TextButton"
                        DataField="DateTime" AutoPostBackOnFilter="true" CurrentFilterFunction="contains" ShowFilterIcon="false" >
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="ConfigName" HeaderText="Config Name" HeaderButtonType="TextButton"
                        DataField="ConfigName" AutoPostBackOnFilter="true" CurrentFilterFunction="contains" ShowFilterIcon="false" >
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="LinesImported" HeaderText="Lines Imported" HeaderButtonType="TextButton"
                        DataField="LinesImported" AutoPostBackOnFilter="true" CurrentFilterFunction="contains" ShowFilterIcon="false" >
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="Status" HeaderText="Status" HeaderButtonType="TextButton"
                        DataField="Status" AutoPostBackOnFilter="true" CurrentFilterFunction="contains" ShowFilterIcon="false" >
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="ErrorMessage" HeaderText="Error Message" HeaderButtonType="TextButton"
                        DataField="ErrorMessage" AutoPostBackOnFilter="true" CurrentFilterFunction="contains" ShowFilterIcon="false" >
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>

 

I have a bound column titled 'Rejected Lines' in the child grid, I am trying to sum it up and display it as a seperate column in the parent grid titled 'Total Rejected Lines'. I know this is pretty straightforward for some of you but I have been struggling with this for quite sometime now. Any help will be appreciated !

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 10 Jul 2015, 01:16 PM
Hi Emaad,

Actually, this is not so straightforward as it sounds. I've created a sample RadGrid web site to demonstrate how you can achieve this requirement. Please run the attached application and let me know if it helps you.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Emaad
Top achievements
Rank 1
answered on 10 Jul 2015, 04:06 PM

Hello Eyup,

 

Thanks for reply, it does work partially but when I first launch my page it total column contains 'System.Data.DataRowView' but when I expand it then the total field gets filled with the aggregate sum.

 

Best,

 

0
Eyup
Telerik team
answered on 15 Jul 2015, 10:49 AM
Hello Emaad,

Could you verify whether you've set the following property?
<MasterTableView ... HierarchyLoadMode="ServerBind">

Looking forward to your reply.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Emaad
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Emaad
Top achievements
Rank 1
Share this question
or