找回密码
 立即注册

QQ登录

只需一步,快速开始

oraclexp79

初级会员

27

主题

45

帖子

220

积分

初级会员

积分
220
oraclexp79
初级会员   /  发表于:2018-11-5 14:31  /   查看:2952  /  回复:1
本帖最后由 oraclexp79 于 2018-11-5 15:05 编辑

this.reportGrid.collapseGroupsToLevel(0); //折叠
为什么我用以上js代码分组折叠后,对应的字段汇总数字是0呢?
另外再请问一下,groupPanel有封装如何获取groupPanel上的按钮焦点事件方法吗?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

1 个回复

倒序浏览
JeffryLI
葡萄城公司职员   /  发表于:2018-11-5 16:54:41
沙发
关于汇总,请参考这这段代码
  1. onload = function () {

  2.   // generate some random data
  3.   var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
  4.                   products = 'Phones,Computers,Cameras,Stereos'.split(','),
  5.       data = [];
  6.   for (var i = 0; i < 200; i++) {
  7.     data.push({
  8.             id: i,
  9.       country: countries[i % countries.length],
  10.       product: products[i % products.length],
  11.       sales: Math.random() * 10000,
  12.       expenses: Math.random() * 5000,
  13.     });
  14.         }
  15. groupPanel上没有监听点击事件。
  16.         // create a group to show the grand totals
  17.         var grandTotalsGroup = new wijmo.collections.PropertyGroupDescription('Grand Total',
  18.           function(item, propName) {
  19.        return '';
  20.     }
  21.         );  

  22.         // grid with custom aggregates
  23.   var theGrid = new wijmo.grid.FlexGrid('#theGrid', {
  24.           autoGenerateColumns: false,
  25.           columns: [ // column definitions with aggregates
  26.                   { binding: 'id', header: 'ID', width: 60, isReadOnly: true },
  27.             { binding: 'country', header: 'Country' },
  28.             { binding: 'product', header: 'Product' },
  29.             { binding: 'sales', header: 'Sales', aggregate: 'Sum' },
  30.             { binding: 'expenses', header: 'Expenses', aggregate: 'Sum' },
  31.       { binding: 'profit', header: 'Profit', dataType: 'Number', isReadOnly: true }
  32.           ],
  33.     itemsSource: new wijmo.collections.CollectionView(data, {
  34.             groupDescriptions: [
  35.               grandTotalsGroup,
  36.         'country'
  37.       ]
  38.     })
  39.   });
  40.   
  41.   // start collapsed
  42.         theGrid.collapseGroupsToLevel(1);
  43.   
  44.   // custom cell calculation
  45.   theGrid.formatItem.addHandler(function(s, e) {
  46.   
  47.           // cells and column footer panels only
  48.     if (e.panel == s.cells) {

  49.                         // get row, column, and data item (or group description)
  50.                         var r = s.rows[e.row];
  51.       var c = s.columns[e.col];
  52.       var item = s.rows[e.row].dataItem;
  53.                         var group = r instanceof wijmo.grid.GroupRow ? item : null;
  54.       
  55.       // assume value is not negative
  56.       var negative = false;

  57.                         // calculate profit
  58.       if (c.binding == 'profit') {
  59.               var profit = group
  60.                       ? group.getAggregate('Sum', 'sales') - group.getAggregate('Sum', 'expenses')
  61.                 : item.sales - item.expenses;
  62.         e.cell.textContent = wijmo.Globalize.format(profit, c.format);
  63.         negative = profit < 0;
  64.       }

  65.                         // update 'negative' class on cell
  66.                         wijmo.toggleClass(e.cell, 'negative', negative);
  67.     }
  68.    
  69.   });
  70. }
复制代码
请点击评分,对我5分评价,谢谢!

葡萄城控件服务团队
官方网站: https://www.grapecity.com.cn/developer
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部