[CLOSED] Show sum in groupping view

  1. #1

    [CLOSED] Show sum in groupping view

    Hi,

    I have a grid panel group by date and I show the date text "Date" - PATRICK

    I would like change "PATRICK" text for view sum of quantity, value in my grid for each date. Can I replace "PATRICK" by this sum?

    Thanks.

    
    
    <script type="text/javascript">
    
    
    var dateRenderer = function() 
    {
    
    
    return Ext.util.Format.dateRenderer('<%= ViewData["DateFormatJs"]%>');
    
    }
    
    </script>

    
    
    <ext:Panel ID="panel2" Title="<%$Resources:ResStr, ApprovalPanel_Approval%>" ColumnWidth="0.75"
    
    Layout="Fit" runat="server">
    
    <Items>
    
    <ext:GridPanel ID="gridPanelApproval" Border="false" runat="server" StoreID="approvalStore">
    
    <ColumnModel>
    
    <Columns>
    
    <uc:Column ColumnID="fieldDate" DataIndex="Date" Header="<%$Resources:ResStr, ApprovalInfoCol_Date%>" Hidden="true">
    
    <Renderer Fn="dateRenderer()" />
    
    </uc:Column>
    
    <uc:Column ColumnID="fieldApprovalLevel" DataIndex="ApprovalLevel" Header="<%$Resources:ResStr, ApprovalInfoCol_Level%>">
    
    <Renderer Fn="formatLevel" />
    
    </uc:Column>
    
    <uc:Column ColumnID="fieldApprovalDate" DataIndex="ApprovalDate" Header="<%$Resources:ResStr, ApprovalInfoCol_ApprovalDate%>">
    
    <Renderer Fn="dateRenderer()" />
    
    </uc:Column>
    
    <uc:Column ColumnID="fieldApproverName" DataIndex="ApproverName" Header="<%$Resources:ResStr, ApprovalInfoCol_ApproverName%>" />
    
    <uc:DecimalColumn ColumnID="fieldQuantity" DataIndex="Quantity" Header="<%$Resources:ResStr, ApprovalInfoCol_Quantity%>"
    
    Align="right">
    
    </uc:DecimalColumn>
    
    <uc:CheckColumn ColumnID="fieldIsApproved" DataIndex="IsApproved" Header="<%$Resources:ResStr, ApprovalInfoCol_Approved%>"
    
    Hideable="false" Editable="true">
    
    </uc:CheckColumn>
    
    <uc:Column ColumnID="fieldClient" DataIndex="ClientName" Header="<%$Resources:ResStr, ApprovalInfoCol_Client%>" />
    
    <uc:Column ColumnID="fieldDescription" DataIndex="Description" Header="<%$Resources:ResStr, ApprovalInfocol_Description%>" />
    
    <uc:Column ColumnID="fieldProjet" DataIndex="ProjectName" Header="<%$Resources:ResStr, ApprovalInfoCol_Projet%>" />
    
    <uc:Column ColumnID="fieldCodeDePaie" DataIndex="PayCode" Header="<%$Resources:ResStr, ApprovalInfoCol_CodeDePaie%>" />
    
    <uc:CheckColumn ColumnID="fieldFacturable" DataIndex="IsBillable" Header="<%$Resources:ResStr, ApprovalInfoCol_Facturable%>"
    
    Hideable="false" Editable="false">
    
    </uc:CheckColumn>
    
    </Columns>
    
    </ColumnModel>
    
    <View>
    
    <ext:GroupingView ID="GroupingView1" HideGroupedColumn="false" runat="server" ForceFit="true"
    
    GroupTextTpl='{text} - PATRICK' EnableRowBody="true">
    
    <GetRowClass Handler="var d = record.data; rowParams.body = ''" />
    
    </ext:GroupingView>
    
    </View>
    
    <Listeners>
    
    <BeforeEdit Handler="onBeforeEditApproval(e);" />
    
    <AfterEdit Handler="enableApplyCancel(true);" />
    
    </Listeners>
    
    <LoadMask ShowMask="true" />
    
    </ext:GridPanel>
    
    </Items>
    
    </ext:Panel>
    Last edited by geoffrey.mcgill; Jul 07, 2010 at 3:41 AM.
  2. #2

    RE: Show sum in groupping view

    Hello!

    Please use
    GroupTextTpl='{text} - {[values.rs.length]}'
    instead of
    GroupTextTpl='{text} - PATRICK'
  3. #3

    RE: Show sum in groupping view

    Hi,

    Thank you for your reply. This code can show row number and I want show my database information. My field quantity is in database.

    This is a screenshot for help you to understand.

    Thanks.
  4. #4

    RE: Show sum in groupping view

    Now I understand, thanks.

    Please add some things in your code:
    1.In a GroupingView control:
    <Listeners>
                        <BeforeRefresh Fn="addStartGroup"/>
    </Listeners>
    2. In the <head> of your page:
    <script type="text/javascript">    
            var addStartGroup = function(gv) {
                gv.startGroup = new Ext.XTemplate(
                      '<div id="{groupId}" class="x-grid-group {cls}">',
                      '<div id="{groupId}-hd" class="x-grid-group-hd" style="{style}"><div class="x-grid-group-title">',
                      '{text} (total: {[this.calcTotal(values.rs)]})',
                      '
    
    <div id="{groupId}-bd" class="x-grid-group-body">',
                    {
                        calcTotal: function(valuesRs) {
                            for (var sum = 0, i = 0, len = valuesRs.length; i < len; i++) {
                                sum += valuesRs[i].get('Quantity');
                            }
                            return sum;
                        }
                    }
                )
            }
    </script>

Similar Threads

  1. [CLOSED] Calendar: Is it possible to set 2 weeks view to show the event?
    By csssi_coolite in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: May 14, 2012, 8:54 AM
  2. Replies: 2
    Last Post: Apr 04, 2012, 9:33 AM
  3. Replies: 2
    Last Post: Feb 14, 2012, 9:57 PM
  4. Replies: 4
    Last Post: Dec 18, 2009, 7:18 PM
  5. [CLOSED] Groupping Summary with Paging Toolbar
    By tdracz in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 12, 2009, 4:07 PM

Posting Permissions