找回密码
 立即注册

QQ登录

只需一步,快速开始

[已处理] 单元格赋值

wss.
初级会员   /  发表于:2020-6-28 18:46:04
10#
KevinChen 发表于 2020-6-28 18:13
尝试换个思路,用持续编辑模式触发beginningEdit试试:

https://demo.grapecity.com.cn/wijmo/demos/Gri ...

不行欸,这样的话就不能选择区域了
回复 使用道具 举报
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-6-29 09:25:50
11#
那只能考虑把click事件挂载到cell的dom上了,可以参考这段代码:

  1. theGrid.cells.hostElement.addEventListener('click', function (e) {
  2.         var click = theGrid.selection;
  3.         alert(`You click at cell position [${click.row},${click.col}] `);
  4.     });
复制代码
回复 使用道具 举报
wss.
初级会员   /  发表于:2020-7-2 16:13:03
12#
KevinChen 发表于 2020-6-29 09:25
那只能考虑把click事件挂载到cell的dom上了,可以参考这段代码:

你好,上次哪个附件的代码为什么不能回选当前值呢
回复 使用道具 举报
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-7-2 17:05:34
13#
你好,没明白您的意思,能否具体描述一下?如果有图文配合就更好了
回复 使用道具 举报
wss.
初级会员   /  发表于:2020-7-2 17:09:42
14#
KevinChen 发表于 2020-7-2 17:05
你好,没明白您的意思,能否具体描述一下?如果有图文配合就更好了

就是我在CustomGridEditor 的  _beginningEdit不是重新设置了下拉框的下拉值itemsSource,然后我再次进行编辑的时候当前单元格本来显示的是“其他”,然后进入编辑模式没有回选值了(默认回选成第一个的值)   
我看了下问题,就是因为我这个itemsSource变化影响他的回选效果
回复 使用道具 举报
wss.
初级会员   /  发表于:2020-7-2 17:14:24
15#
wss. 发表于 2020-7-2 17:09
就是我在CustomGridEditor 的  _beginningEdit不是重新设置了下拉框的下拉值itemsSource,然后我再次进行 ...

可以再详细描述一下问题,我动态设置了itemsSource,下次进入编辑的时候selectedItem没值
回复 使用道具 举报
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-7-2 17:32:28
16#
你好,实际上在本帖的示例中,你的combobox中展示的是一个json对象,而不是普通的字符串,所以在CustomGridEditor 的174行处不能用this._ctl['text'] 赋值,而应该用
this._ctl['selectedItem'] 赋值对应的item,参考代码:

  1. /*
  2.                                         展开后把值回填
  3.                                 */
  4.                                 if (!wijmo.isUndefined(this._ctl['text'])) {
  5.                                         // Combobox下拉的item是json对象,需要通过selectedItem设置
  6.                                         let cellData = grid.getCellData(this._rng.row, this._rng.col, true);
  7.                                         let selectedItem = null;
  8.                                         this._ctl.itemsSource.forEach(function(item){
  9.                                                 if(item && item.cText && item.cText == cellData){
  10.                                                         selectedItem = item;
  11.                                                 }
  12.                                         })
  13.                                         if(selectedItem){
  14.                                                 this._ctl['selectedItem'] = selectedItem;
  15.                                         }else{
  16.                                                 this._ctl['text'] = cellData;
  17.                                         }
  18.                                 } else {
  19.                                         throw 'Can\'t set editor value/text...';
  20.                                 }
复制代码
回复 使用道具 举报
12
您需要登录后才可以回帖 登录 | 立即注册
返回顶部