找回密码
 立即注册

QQ登录

只需一步,快速开始

且随疾风前行

注册会员

2

主题

2

帖子

10

积分

注册会员

积分
10
最新发帖
且随疾风前行
注册会员   /  发表于:2020-6-1 17:39  /   查看:3057  /  回复:1
1金币
问题: grid分组后自定义分组栏所在行的高度

         
        尝试过用groupHeaderFormat去定义,但是不起作用。涉及到公司安全信息,代码就不贴出来了


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

最佳答案

查看完整内容

您好,您的帖子应该是发到了其它的板块,所以没能及时看到和回复,抱歉。 这个问题可以用事件来解决,参考代码: 在 FlexGrid的updatedView事件中,判断当前的行是否GroupRow类型,如果是,更改它的高度即可。 完整代码请参考: 将以上代码完整复制,替换掉示例的App.js即可看到效果: https://demo.grapecity.com.cn/wijmo/demos/Grid/Grouping/Groups/purejs

1 个回复

倒序浏览
最佳答案
最佳答案
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-6-1 17:39:34
来自 2#
您好,您的帖子应该是发到了其它的板块,所以没能及时看到和回复,抱歉。

这个问题可以用事件来解决,参考代码:

  1.     theGrid.updatedView.addHandler(function(s,e){
  2.         var rows = s.rows;
  3.         rows.forEach(function(row){
  4.             if(row && (row instanceof wjGrid.GroupRow)){
  5.                 row.height = 50;
  6.             }
  7.         });
  8.     });
复制代码


在 FlexGrid的updatedView事件中,判断当前的行是否GroupRow类型,如果是,更改它的高度即可。

完整代码请参考:

  1. import 'bootstrap.css';
  2. import '@grapecity/wijmo.styles/wijmo.css';
  3. import './styles.css';
  4. import * as wjGrid from '@grapecity/wijmo.grid';
  5. import * as wjCore from '@grapecity/wijmo';
  6. //
  7. document.readyState === 'complete' ? init() : window.onload = init;
  8. //
  9. function init() {
  10.     //
  11.     // generate some random data
  12.     var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), products = 'Phones,Computers,Cameras,Stereos'.split(','), data = [];
  13.     for (var i = 0; i < 200; i++) {
  14.         data.push({
  15.             id: i,
  16.             country: countries[i % countries.length],
  17.             product: products[i % products.length],
  18.             downloads: Math.round(100 + Math.random() * 10000),
  19.             sales: Math.random() * 10000,
  20.             expenses: Math.random() * 5000,
  21.         });
  22.     }
  23.     //
  24.     // basic grouping
  25.     var theGrid = new wjGrid.FlexGrid('#theGrid', {
  26.         itemsSource: new wjCore.CollectionView(data, {
  27.             sortDescriptions: ['country', 'product'],
  28.             groupDescriptions: ['country', 'product']
  29.         })
  30.     });
  31.     //
  32.     // select first item (after sorting/grouping)
  33.     theGrid.select(new wjGrid.CellRange(0, 0), true);
  34.     theGrid.updatedView.addHandler(function(s,e){
  35.         var rows = s.rows;
  36.         rows.forEach(function(row){
  37.             if(row && (row instanceof wjGrid.GroupRow)){
  38.                 row.height = 50;
  39.             }
  40.         });
  41.     });
  42.     //
  43.     // hide columns being grouped on
  44.     var theGridHideCols = new wjGrid.FlexGrid('#theGridHideCols', {
  45.         autoGenerateColumns: false,
  46.         columns: [
  47.             { binding: 'country', header: 'Country', visible: false },
  48.             { binding: 'product', header: 'Product', visible: false },
  49.             { binding: 'downloads', header: 'Downloads', width: '*' },
  50.             { binding: 'sales', header: 'Sales', width: '*' },
  51.             { binding: 'expenses', header: 'Expenses', width: '*' },
  52.         ],
  53.         itemsSource: new wjCore.CollectionView(data, {
  54.             sortDescriptions: ['country', 'product'],
  55.             groupDescriptions: ['country', 'product']
  56.         })
  57.     });
  58.     //
  59.     // select first item (after sorting/grouping)
  60.     theGridHideCols.select(new wjGrid.CellRange(0, 2), true);
  61.    
  62. }
复制代码


将以上代码完整复制,替换掉示例的App.js即可看到效果:
https://demo.grapecity.com.cn/wi ... uping/Groups/purejs
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部