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

4 posts, 0 answers
  1. Emaad
    Emaad avatar
    2 posts
    Member since:
    May 2015

    Posted 07 Jul 2015 Link to this post

    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 !

  2. Eyup
    Admin
    Eyup avatar
    3690 posts

    Posted 10 Jul 2015 Link to this post

    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
  3. Emaad
    Emaad avatar
    2 posts
    Member since:
    May 2015

    Posted 10 Jul 2015 in reply to Eyup Link to this post

    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,

     

  4. Eyup
    Admin
    Eyup avatar
    3690 posts

    Posted 15 Jul 2015 Link to this post

    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
Back to Top