请选择 进入手机版 | 继续访问电脑版
 找回密码
 立即注册

QQ登录

只需一步,快速开始

mtkj
金牌服务用户   /  发表于:2020-6-24 17:38  /   查看:5670  /  回复:10
1金币

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

最佳答案

查看完整内容

可以考虑用 updatedView事件,这个事件是当Grid表格的view发生变化时触发,触发事件后可以遍历当前显示的单元格,判断样式,再挂载相应的样式。

10 个回复

倒序浏览
最佳答案
最佳答案
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-6-24 17:38:19
来自 11#
可以考虑用 updatedView事件,这个事件是当Grid表格的view发生变化时触发,触发事件后可以遍历当前显示的单元格,判断样式,再挂载相应的样式。
回复 使用道具 举报
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-6-24 18:34:40
2#
你好,这个问题需要调研,预计28号上午回复
回复 使用道具 举报
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-6-28 11:57:31
3#
您好,经测试,只需要给cssClassAll赋值为空字符串即可,参考代码:

  1. row.cssClassAll = "";
复制代码


完整代码:

  1. import 'bootstrap.css';
  2. import '@grapecity/wijmo.styles/wijmo.css';
  3. import './styles.css';
  4. import * as wjGrid from '@grapecity/wijmo.grid';
  5. //
  6. document.readyState === 'complete' ? init() : window.onload = init;
  7. //
  8. function init() {
  9.     //
  10.     // generate some random data
  11.     var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), products = 'Phones,Computers,Cameras,Stereos'.split(','), data = [];
  12.     for (var i = 0; i < 200; i++) {
  13.         data.push({
  14.             id: i,
  15.             country: countries[i % countries.length],
  16.             product: products[i % products.length],
  17.             sales: Math.random() * 10000,
  18.             expenses: Math.random() * 5000,
  19.         });
  20.     }
  21.     //
  22.     // column properties
  23.     var theGrid = new wjGrid.FlexGrid('#theGrid', {
  24.         autoGenerateColumns: false,
  25.         alternatingRowStep: 0,
  26.         columns: [
  27.             { binding: 'id', header: 'ID', width: 50 },
  28.             { binding: 'country', header: 'Country', },
  29.             { binding: 'product', header: 'Product', },
  30.             { binding: 'sales', header: 'Sales', format: 'c0' },
  31.             { binding: 'expenses', header: 'Expenses', format: 'c0' },
  32.         ],
  33.         loadedRows: function (s, e) {
  34.             for (var i = 0; i < s.rows.length; i++) {
  35.                 var row = s.rows[i];
  36.                 var item = row.dataItem;
  37.                 if (item.sales > 6000) {
  38.                     row.cssClassAll = 'high-value';
  39.                 }
  40.                 else if (item.sales < 1000) {
  41.                     row.cssClassAll = 'low-value';
  42.                 }
  43.             }
  44.         },
  45.         itemsSource: data
  46.     });

  47.     theGrid.rows.forEach(function(row){
  48.         row.cssClassAll = "";
  49.     })

  50.     //
  51.     // toggle alternatingRowStep
  52.     document.getElementById('alternatingRowStep').addEventListener('click', function (e) {
  53.         theGrid.alternatingRowStep = e.target.checked ? 1 : 0;
  54.     });
  55.     //
  56. }
复制代码


测试地址:

https://demo.grapecity.com.cn/wi ... ows/Overview/purejs
回复 使用道具 举报
mtkj
金牌服务用户   /  发表于:2020-6-29 15:57:42
4#
KevinChen 发表于 2020-6-28 11:57
您好,经测试,只需要给cssClassAll赋值为空字符串即可,参考代码:



本帖子中包含更多资源

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

x
回复 使用道具 举报
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-6-29 17:02:01
5#
OK,问题已收到,我这边验证一下
回复 使用道具 举报
mtkj
金牌服务用户   /  发表于:2020-7-7 15:08:03
6#
KevinChen 发表于 2020-6-29 17:02
OK,问题已收到,我这边验证一下

这个问题找到解决办法没
回复 使用道具 举报
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-7-7 18:44:15
7#
你好,我这边没能重现这个问题,你可以尝试用toggleClass方法删除这个class,API参考:

https://www.grapecity.com/wijmo/api/index.html#toggleclass
回复 使用道具 举报
mtkj
金牌服务用户   /  发表于:2020-7-9 16:28:41
8#
KevinChen 发表于 2020-7-7 18:44
你好,我这边没能重现这个问题,你可以尝试用toggleClass方法删除这个class,API参考:

https://www.gra ...

这个方法得有 e.cell ,我页面这个地方没有这个e.cell, 只知道 行号

本帖子中包含更多资源

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

x
回复 使用道具 举报
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-7-9 18:32:13
9#
你好,使用
theGridFormatItem.cells.getCellElement(0,3)
可以获取到指定位置单元格的Element,
另外,挂载的high-value样式,如果是在formatItem中挂的样式,
那就不能在初始化FlexGrid后立马执行,
因为浏览器这时还有一个渲染的过程。
建议用updatedView事件,或让步设置样式。
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部