Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8738795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:48:17+00:00 2026-06-13T10:48:17+00:00

Following is my code to show a grid panel with total cost summary. I

  • 0

Following is my code to show a grid panel with total cost summary. I want to show another summary row with average. So any help?

    Ext.require(['Ext.data.*', 'Ext.grid.*']);

    Ext.onReady(function() {

    Ext.define('NewEstimate', {
        extend: 'Ext.data.Model',
        fields: ['description', 'cost'],
        validations: [{
            type: 'length',
            field: 'description',
            min: 3
        }, {
            type: 'int',
            field: 'cost',
            min: 1
        }]
    });

    var rowEditing = Ext.create('Ext.grid.plugin.RowEditing');

    var store = Ext.create('Ext.data.Store', {
            autoLoad: true,
            autoSync: false,
            model: 'NewEstimate',
            proxy: {
                type: 'rest',
                url: 'app.php/users',
                reader: {
                    type: 'json',
                    root: 'data'
                },
                writer: {
                    type: 'json'
                }
            },
            listeners: {
                write: function(store, operation){
                    var record = operation.records[0],
                        name = Ext.String.capitalize(operation.action),
                        verb;

                    if (name == 'Destroy') {
                        verb = 'Destroyed';
                    } else {
                        verb = name + 'd';
                        alert(name);
                    }
                    Ext.example.msg(name, Ext.String.format("{0} user: {1}", verb, record.getId()));

                }
            }
        });

    var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
            clicksToEdit: 1,
            listeners: {
                edit: function(){
                    grid.getView().refresh();
                }
            }
        });

    var data = [
        {projectId: 100, taskId: 112, description: 'Integrate 2.0 Forms with 2.0 Layouts', cost: 150},
        {projectId: 100, taskId: 113, description: 'Implement AnchorLayout', cost: 150},
        {projectId: 100, taskId: 114, description: 'Add support for multiple types of anchors', cost: 150},
        {projectId: 100, taskId: 115, description: 'Testing and debugging', cost: 0}
    ];

    var gridPanel = new Ext.create('Ext.grid.Panel', {
        width: 600,
        height: Ext.getBody().getViewSize().height * 0.3,
        renderTo: document.body,
        plugins: [rowEditing],
        features: [{
            ftype: 'summary'
        }
        ],
        store: store,
        columns: [{
            dataIndex: 'description',
            flex: 1,
            text: 'Description',
            summaryType: 'count',
            field: {
                    xtype: 'textfield',
                    allowBlank: false
                },
            summaryRenderer: function(value){
                return Ext.util.Format.leftPad('Estimate Total (EUR)');
            }   
        }, {
            dataIndex: 'cost',
            width: 75,
            text: 'Line Total',

             field: {
                    xtype: 'numberfield',
                    allowBlank: false
                },
            summaryType: function(records){
                    var i = 0,
                        length = records.length,
                        total = 0,
                        record;

                    for (; i < length; ++i) {
                        record = records[i];
                        total = total + Number(record.get('cost'));
                    }
                    return total;
                }
        }],
        dockedItems: [
               {
             xtype: 'toolbar',
                items: [{
                    text: 'Add',
                    iconCls: 'icon-add',
                    handler: function(){
                        // empty record
                        store.insert(0, new NewEstimate());
                        rowEditing.startEdit(0, 0);
                    }
                } , '-', 
                {
                    text: 'Delete',
                    iconCls: 'icon-delete',
                    handler: function(){

                        var selection = gridPanel.getView().getSelectionModel().getSelection()[0];

                        if (selection) {
                            store.remove(selection);
                        }
                    }
                }]
            }]
    });
    });

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:48:19+00:00Added an answer on June 13, 2026 at 10:48 am

    I had a similar need. Given enough time, I’d probably just extend the Summary feature to support multiple aggregates. However, I didn’t have time, so I did a kind of dirty work-around.

    Instead of try to get two rows, I just used summaryType as a function, and returned the value as a string with a BR tag. It’s definitely clunky, but it works for what I need.

    Something like:

    columns: [
       {
          header:'Quantity',
          dataIndex: 'Quantity',
          summaryType"="function( records ) {
             sum = 0;
             for( rec in records ) {
                var record = records[ rec ];
                sum += record.data[ '#guide#_Quantity' ];
             }
             avg= Math.floor( sum/records.length );
             return '<strong>'+ sum + ' Books<br />' + avg + ' Books</strong>';
          }
       }
    ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code should show a certain track in iTunes: NSString* iTunesPath = [[NSWorkspace
I am using following code to show a spinning wheel: $(#loading) .hide() .ajaxStart(function(){ $(this).show();
i have following code to show div on page <div id=all_users> <div id=user11 userid=11
I have the following code to show me a custom list with images and
I have the following code: function show(){ var a=document.getElementById('somediv').style.display; a=block; } The above code
I am using the following code to show some labels and a textview in
I know that the following code should show and hide a tiny circular progress
I am using the following code to show a jQuery UI dialog when the
The following is my code to show One Title followed by one checkboxlist .
I use the following code to hide and show a box on a bunch

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.