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

[Solved] How to sort by an aggregate value

0 Answers 150 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hunter
Top achievements
Rank 1
Hunter asked on 30 Apr 2013, 10:07 PM

After my user drags a column to be grouped (i.e. client, sales person) it generates a summary value (order total) in the group footer.  I want to sort the grouped results by that summary value that shows up in the footer.

Looking for results like this:

Client         Total Amount
ABC Corp   $1000
ABC Corp   $1500
                   $2500

XYZ LLC     $2000
XYZ LLC     $1750
                    $3750

LMN Inc      $4500
                    $4500

If this helps, my static radgrid definition is as follows:

<telerik:RadGrid ID="rgOrders" ShowGroupPanel="True" Width="1300px" Height="750px"
                AutoGenerateColumns="False" AllowPaging="True" PageSize="25" AllowSorting="True"
                runat="server" OnNeedDataSource="rgOrders_NeedDataSource" Skin="WebBlue" OnItemCommand="rgOrders_ItemCommand"
                AllowFilteringByColumn="False" CellSpacing="0" ShowFooter="true" GridLines="None"
                OnItemDataBound="rgOrders_ItemDataBound">
                <ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true"
                    HideStructureColumns="true">
                </ExportSettings>
                <ClientSettings AllowColumnHide="True" AllowColumnsReorder="True" AllowGroupExpandCollapse="True"
                    ReorderColumnsOnClient="True" AllowDragToGroup="True">
                    <Scrolling AllowScroll="False" UseStaticHeaders="True" />
                    <Resizing AllowColumnResize="true" AllowRowResize="true" />
                </ClientSettings>
                <MasterTableView CommandItemDisplay="Top" EnableLinqGrouping="false" ShowGroupFooter="True">
                    <CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true"
                        ShowExportToCsvButton="true" ShowExportToPdfButton="true" ShowAddNewRecordButton="false" />
                    <Columns>
                        <telerik:GridTemplateColumn HeaderText="Edit" ItemStyle-HorizontalAlign="Center"
                            ItemStyle-Width="40" HeaderStyle-Width="40">
                            <ItemTemplate>
                                <asp:imagebutton id="ibtnUpdate" commandname="Edit" runat="server" imageurl="images/silk/pencil_go.png" />
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Order Summary" ItemStyle-HorizontalAlign="Center"
                            ItemStyle-Width="60" HeaderStyle-Width="60">
                            <ItemTemplate>
                                <asp:imagebutton id="ibtnView" commandname="View" runat="server" imageurl="images/1258747021_old-edit-find.png" />
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Set Location" ItemStyle-HorizontalAlign="Center"
                            ItemStyle-Width="60" HeaderStyle-Width="60">
                            <ItemTemplate>
                                <asp:imagebutton id="ibtnLocation" commandname="Location" runat="server" imageurl="images/1366329632_map.png" />
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridBoundColumn DataField="ClientName" ItemStyle-Width="200px" HeaderStyle-Width="200"
                            FilterControlAltText="Filter ClientName column" HeaderText="Client Name" ReadOnly="True"
                            AllowFiltering="false" SortExpression="ClientName" UniqueName="ClientName" AutoPostBackOnFilter="false"
                            CurrentFilterFunction="EqualTo" FilterDelay="4000" ShowFilterIcon="True" />
                        <telerik:GridBoundColumn DataField="OrderID" ItemStyle-Width="75px" HeaderStyle-Width="75px"
                            FilterControlAltText="Filter OrderID column" HeaderText="Order ID" ReadOnly="True"
                            AllowFiltering="false" SortExpression="OrderID" UniqueName="OrderID" />
                        <telerik:GridBoundColumn DataField="OrderDate" DataFormatString="{0:MM/dd/yyyy}"
                            ItemStyle-Width="75px" HeaderStyle-Width="75px" FilterControlAltText="Filter OrderDate column"
                            HeaderText="Order Date" ReadOnly="True" AllowFiltering="True" SortExpression="OrderDate"
                            UniqueName="OrderDate" />
                        <telerik:GridNumericColumn Aggregate="Sum" AllowSorting="true"  DataField="TotalAmount" DataFormatString="{0:C}"
                            ItemStyle-Width="75px" HeaderStyle-Width="75px" FilterControlAltText="Filter TotalAmount column"
                            HeaderText="Total MRR" ReadOnly="True" AllowFiltering="True" SortExpression="TotalAmount"
                            UniqueName="TotalAmount" ItemStyle-HorizontalAlign="Right" />
                        <telerik:GridNumericColumn Aggregate="Sum" AllowSorting="true" DataField="NRC" DataFormatString="{0:C}"
                            ItemStyle-Width="75px" HeaderStyle-Width="75px" FilterControlAltText="Filter NRC column"
                            HeaderText="Total NRC" ReadOnly="True" AllowFiltering="True" SortExpression="NRC"
                            UniqueName="NRC" ItemStyle-HorizontalAlign="Right" />
                        <telerik:GridBoundColumn DataField="OrderStatus" ItemStyle-Width="75px" HeaderStyle-Width="75px"
                            FilterControlAltText="Filter OrderStatus column" HeaderText="Order Status" ReadOnly="True"
                            AllowFiltering="false" SortExpression="OrderStatus" UniqueName="OrderStatus" />
                        <telerik:GridTemplateColumn HeaderText="Invoiced?" ItemStyle-Width="70px" HeaderStyle-Width="70px">
                            <ItemTemplate>
                                <%# GetYesNo(Eval("Invoiced"))%>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridBoundColumn DataField="OrderTrialType" ItemStyle-Width="50px" HeaderStyle-Width="50px"
                            FilterControlAltText="Filter OrderTrialType column" HeaderText="Order Trial?"
                            ReadOnly="True" AllowFiltering="false" SortExpression="OrderTrialType" UniqueName="OrderTrialType" />
                        <telerik:GridBoundColumn DataField="FullName" ItemStyle-Width="100px" HeaderStyle-Width="100px"
                            FilterControlAltText="Filter FullName column" HeaderText="Sales Rep" ReadOnly="True"
                            AllowFiltering="false" SortExpression="FullName" UniqueName="FullName" />
                        <telerik:GridBoundColumn DataField="FirmOrderDeliveryDate" DataFormatString="{0:MM/dd/yyyy}"
                            ItemStyle-Width="75px" HeaderStyle-Width="75px" FilterControlAltText="Filter FirmOrderDeliveryDate column"
                            HeaderText="Target Delivery Date" ReadOnly="True" AllowFiltering="false" SortExpression="FirmOrderDeliveryDate"
                            UniqueName="FirmOrderDeliveryDate" />
                        <telerik:GridBoundColumn DataField="ContractStartDate" DataFormatString="{0:MM/dd/yyyy}"
                            ItemStyle-Width="75px" HeaderStyle-Width="75px" FilterControlAltText="Filter ContractStartDate column"
                            HeaderText="Contract Start Date" ReadOnly="True" AllowFiltering="false" SortExpression="ContractStartDate"
                            UniqueName="ContractStartDate" />
                        <telerik:GridBoundColumn DataField="ContractEndDate" DataFormatString="{0:MM/dd/yyyy}"
                            ItemStyle-Width="75px" HeaderStyle-Width="75px" FilterControlAltText="Filter ContractEndDate column"
                            HeaderText="Contract End Date" ReadOnly="True" AllowFiltering="false" SortExpression="ContractEndDate"
                            UniqueName="ContractEndDate" />
                        <telerik:GridBoundColumn DataField="PM_Name" ItemStyle-Width="100px" HeaderStyle-Width="100px"
                            FilterControlAltText="Filter PM_Name column" HeaderText="Prov. Mgr" ReadOnly="True"
                            AllowFiltering="false" SortExpression="PM_Name" UniqueName="FullPM_NameName" />
                        <telerik:GridBoundColumn DataField="BillingFrequency" FilterControlAltText="Filter BillingFrequency column"
                            HeaderText="Billing Frequency" ReadOnly="True" AllowFiltering="false" SortExpression="BillingFrequency"
                            UniqueName="BillingFrequency" />
                        <telerik:GridButtonColumn ConfirmText="Mark Inactive?" ConfirmDialogType="RadWindow"
                            ItemStyle-Width="50" HeaderStyle-Width="50" ConfirmTitle="Mark Inactive?" ButtonType="ImageButton"
                            CommandName="MakeInactive" Text="Mark Inactive?" UniqueName="MarkInactiveColumn"
                            ImageUrl="images/1263447248_cross.png">
                            <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton"></ItemStyle>
                        </telerik:GridButtonColumn>
                    </Columns>
                    <EditFormSettings>
                        <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                        </EditColumn>
                    </EditFormSettings>
                </MasterTableView>
                <GroupingSettings ShowUnGroupButton="true" />
                <PagerStyle PageSizes="25,50,100,250 " />
            </telerik:RadGrid>


Any help is appreciated.  Thanks.
Hunter

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Hunter
Top achievements
Rank 1
Share this question
or