The problem of adding a total row to the ExtJS page

Source: Internet
Author: User
It is too troublesome to add a total line to the ExtJS page in the background code. Here is a simple method. // Aggregate function BeginfunctionGridSum (grid) {varsum10; // store the total value of the first column... syntaxHighlighter. all (); it is too troublesome to add a total line to the ExtJS page in the background code. Here is a simple method. // Aggregate function Begin function GridSum (grid) {var sum1 = 0; // store the total value of the first column var sum2 = 0; // store the total value of the second column //... several columns need to be aggregated to declare several variable grids. store. each (function (record) {// function grid. store. each (record) is equivalent to a for loop, traversing the entire record sum1 + = Number (record. data. money1); // sum all values in the money1 column and calculate sum2 + = Number (record. data. money2); // Add all values under the money2 column}); var p = new Ext. data. record ({money1: sum1, // match money1 with the total value money2: sum2 // match money2 with the total value }); grid. store. insert (0, p); // insert to the first row of the current page // grid. store. insert (grid. getStore (). getCount (), p); // insert to the last row of the current page, function grid. getStore (). getCount () is used to obtain the number of record rows on the current page} // total function End // After the load event in the Store is triggered, the aggregate function is called. http://www.52mvc.com Asp.net gridui. getStore (). on ('load', function () {GridSum (gridui. getGrid (); // call the aggregate function. gridui is the gridui variable name defined on your page. It is passed as a parameter to GridSum () function}). Note: 1. money1 and money2 are the "dataIndex" attribute values corresponding to the "Money 1" column and "money 2" column on your page. 2. When the load event of the Store is "just entering the page" and "click Next", it will be triggered when "Click query. 3. This method is used to aggregate the values on the current page. The sum of values on all pages is not counted. When you click the next page, the total values on the next page are automatically calculated and displayed.

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.