How to add a Total row in a Magento grid

Source: Internet
Author: User

Add these fields to your gird class
Class * * * extends mage_adminhtml_block_widget_grid{protected $_counttotals = true;        Public Function Gettotals () {$totals = new varien_object (); $fields = Array (' Uzkart_trans_amount ' = 0,//actual column index, see _preparecolumns () ' some_s        Ummarable_field ' = 0, ' Another_countable_field ' and ' 0, '; foreach ($this->getcollection () as $item) {foreach ($fields as $field = $value) {$fields [$f            ield]+= $item->getdata ($field);        }}//first column in the grid $fields [' entity_id ']= ' Totals ';        $totals->setdata ($fields);    return $totals; } protected function _preparecolumns () {/** * Another columns */$this->addcolumn ( ' Uzkart_trans_amount ', Array (' header ' = Mage::helper (' Uzkart ')->__ (' Payment amount '), ' Index ' = ' uzkart_trans_amount ', ' type ' = ' currency '‘, )); /** * Another columns */}/** * Another methods */}
But there are other question
Hide the Action Column in totals and more
Add ' totals_label ' = ' In your action column

How to add a Total row in a Magento grid

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.