找回密码
 立即注册

QQ登录

只需一步,快速开始

mtkj
金牌服务用户   /  发表于:2020-8-21 11:34  /   查看:3690  /  回复:8
1金币

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

最佳答案

查看完整内容

感谢反馈,本帖结贴了,有新的问题欢迎发新帖交流~

8 个回复

倒序浏览
最佳答案
最佳答案
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-8-21 11:34:38
来自 9#
感谢反馈,本帖结贴了,有新的问题欢迎发新帖交流~
回复 使用道具 举报
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-8-21 15:27:10
2#
您好,这个问题正在处理,预计2小时左右回复
回复 使用道具 举报
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-8-21 19:51:55
3#
你好,只需要把数字类型的数据改为字符串即可,参考示例:
https://demo.grapecity.com.cn/wi ... nding/Basics/purejs

  1. import 'bootstrap.css';
  2. import '@grapecity/wijmo.styles/wijmo.css';
  3. import { SortDescription, format } from '@grapecity/wijmo';
  4. import { FlexGrid } from '@grapecity/wijmo.grid';
  5. document.readyState === 'complete' ? init() : window.onload = init;
  6. function init() {
  7.     // create some random data
  8.     var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(',');
  9.     var data = [];
  10.     for (var i = 0; i < countries.length; i++) {
  11.         data.push({
  12.             id: i,
  13.             country: countries[i],
  14.             sales: Math.random() * 10000+"",
  15.             expenses: Math.random() * 5000+""
  16.         });
  17.     }
  18.     // bind a grid to the raw data
  19.     var theGrid = new FlexGrid('#theGrid', {
  20.         allowSorting: false,
  21.         showSort: false,
  22.         autoGenerateColumns: false,
  23.         columns: [
  24.             { binding: 'country', header: 'Country', width: '2*' },
  25.             { binding: 'sales', header: 'Sales', width: '*'},
  26.             { binding: 'expenses', header: 'Expenses', width: '*', format: 'n2' }
  27.         ],
  28.         itemsSource: data
  29.     });
  30.     // show the current item
  31.     var selItemElement = document.getElementById('selectedItem');
  32.     function updateCurrentInfo() {
  33.         selItemElement.innerHTML = format('Country: <b>{country}</b>, Sales: <b>{sales:c0}</b> Expenses: <b>{expenses:c0}</b>', theGrid.collectionView.currentItem);
  34.     }
  35.     // update current item now and when the grid selection changes
  36.     updateCurrentInfo();
  37.     theGrid.collectionView.currentChanged.addHandler(updateCurrentInfo);
  38.     // sort the data by country
  39.     var sd = new SortDescription('country', true);
  40.     theGrid.collectionView.sortDescriptions.push(sd);
  41. }
复制代码
回复 使用道具 举报
mtkj
金牌服务用户   /  发表于:2020-8-22 14:07:58
4#
这个直接变成了字符串型的,在搜索时,就不能自动求和了,想要的结果是,该显示多少小数,就显示多少小数,并且是字符串型的单元格,并且能够搜索,编辑时自动求和

本帖子中包含更多资源

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

x
回复 使用道具 举报
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-8-24 14:50:19
5#
以附件Demo中代码为例,两处需要修改:
1、290行,数量列的配置项中,需要指定列数据的类型,这里默认为2,设置为1即可,API:

https://demo.grapecity.com.cn/wijmo/api/enums/wijmo.datatype.html
如图:


2、477行,这里给setCellData传入的参数col本身并不是一个数字,而是column对象,需要调用一级才行
如图:


这个问题与另一个帖子的问题相同,关联入口:
https://gcdn.grapecity.com.cn/forum.php?mod=viewthread&tid=79831&extra=page%3D1

本帖子中包含更多资源

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

x
回复 使用道具 举报
mtkj
金牌服务用户   /  发表于:2020-8-25 11:41:14
6#
本帖最后由 mtkj 于 2020-8-25 11:44 编辑

   求和的地方变两位数了,四舍五入了

本帖子中包含更多资源

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

x
回复 使用道具 举报
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-8-25 13:57:15
7#
你好,这里既然是自己计算的,把数字类型转为字符串型就可以了嘛,如图:

本帖子中包含更多资源

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

x
回复 使用道具 举报
mtkj
金牌服务用户   /  发表于:2020-8-25 15:45:09
8#
好了,谢谢
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部