找回密码
 立即注册

QQ登录

只需一步,快速开始

IT-Weaver

初级会员

20

主题

76

帖子

238

积分

初级会员

积分
238
IT-Weaver
初级会员   /  发表于:2021-11-15 16:46  /   查看:1505  /  回复:1
1金币


【V12】通过celltype页面弹框时,cell没有失去焦点,还会重复激活输入事件。



自定义的celltype,继承了new GC.Spread.Sheets.CellTypes.Text(),通过activateEditor事件,进行了一个弹框业务处理,但是弹框出来后,键盘输入时,仍然激活的时spread的cell输入事件,输入的东西不能正常的输入到弹框页面中。


  1. import GC from '@grapecity/spread-sheets'

  2. let CZElementCellTypeV12 = function CZElementCellTypeV12(columnTag, csList, showStyle, _parent, sourceElementEditOff, setTableData) {
  3.     this.ColumnInfo = columnTag
  4.     this.CSList = csList
  5.     this.ShowStyle = showStyle
  6.     this._parent = _parent
  7.     this.sourceElementEditOff = sourceElementEditOff
  8.     this.setTableData = setTableData
  9. }

  10. CZElementCellTypeV12.prototype = new GC.Spread.Sheets.CellTypes.Text() // new GcSpread.Sheets.TextCellType()

  11. CZElementCellTypeV12.prototype.deactivateEditor = function (editorContext, context) {
  12.     // alert("deactivateEditor4");
  13. }
  14. CZElementCellTypeV12.prototype.getEditorValue = function (editorContext, cellStyle, cellRect, context) {
  15.     // alert("getEditorValue3");
  16. }
  17. CZElementCellTypeV12.prototype.setEditorValue = function (editorContext, cellStyle, cellRect, context) {
  18.     // alert("setEditorValue1");
  19. }
  20. CZElementCellTypeV12.prototype.updateEditor = function (editorContext, cellStyle, cellRect, context) {
  21.     // alert("updateEditor2");
  22. }

  23. CZElementCellTypeV12.prototype.activateEditor = function (editorContext, cellStyle, cellRect, context) {
  24.     let row = context.row
  25.     let col = context.col
  26.     let gridhelper = new GridHelperV12(this._parent.spread)
  27.     let oldValue = gridhelper.GetCellValue(row, col)
  28.     let that = this
  29.     // this._parent.spread.getActiveSheet().startEdit(false);
  30.     this._parent.$faspDialog({
  31.         config: {
  32.             width: '500px',
  33.             title: '请选择<' + that.ColumnInfo.columnName + '>',
  34.             center: false
  35.         },
  36.         vmcolumnId: that.ColumnInfo.vmColumnID,
  37.         VoucherId: that.ColumnInfo.voucherID,
  38.         RuleId: that._parent.RuleId,
  39.         BusiDate: that._parent.BusiDate,
  40.         isMultiple: false,
  41.         sourceElement: that.ColumnInfo.sourceElement,
  42.         funcTableData: that.setTableData,
  43.         cickHoder: that._parent,
  44.         cameBackData: function (data) {
  45.             if (data != null && data !== '' && data !== 'undefined') {
  46.                 let checkMode = JSON.parse(data)
  47.                 gridhelper.SetCellValue(row, col, checkMode[0].id)
  48.             } else {
  49.                 gridhelper.SetCellValue(row, col, null)
  50.             }
  51.             let newValue = gridhelper.GetCellValue(row, col)
  52.             // that.sourceElementEditOff(that._parent, context, oldValue, newValue)
  53.         }
  54.     })
  55. }

  56. CZElementCellTypeV12.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
  57.     try {
  58.         if (value) {
  59.             if (value == '0') {
  60.                 GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, [ctx, value, x, y, w, h, style, options]);
  61.                 return
  62.             }
  63.             let findvalue = this.CSList.find(t => t.key == value)
  64.             if (findvalue != null && findvalue !== 'undefined') {
  65.                 // console.log(findvalue);
  66.                 if (this.ShowStyle === 1) {
  67.                     GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, [ctx, findvalue.itemCode, x, y, w, h, style, options])
  68.                 } else if (this.ShowStyle == 2) {
  69.                     GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, [ctx, findvalue.itemName, x, y, w, h, style, options])
  70.                 } else {
  71.                     GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, [ctx, '[' + findvalue.itemCode + ']' + findvalue.itemName, x, y, w, h, style, options])
  72.                 }
  73.             } else {
  74.                 GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, [ctx, value, x, y, w, h, style, options])
  75.               //  console.log('undefined');
  76.             }
  77.         } else {
  78.             if (value == '0') {
  79.                 GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, [ctx, value, x, y, w, h, style, options])
  80.             } else {
  81.                 GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, [ctx, value, x, y, w, h, style, options])
  82.             }
  83.         }
  84.     } catch (e) {
  85.         console.log(e);
  86.     }
  87. }

  88. window.CZElementCellTypeV12 = CZElementCellTypeV12
复制代码


请帮忙解答,谢谢。

最佳答案

查看完整内容

我看到你在spreadjs版本已经发了新帖, https://gcdn.grapecity.com.cn/forum.php?mod=viewthread&tid=136332 此帖就关闭处理了

1 个回复

倒序浏览
最佳答案
最佳答案
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2021-11-15 16:46:22
来自 2#
我看到你在spreadjs版本已经发了新帖,
https://gcdn.grapecity.com.cn/fo ... read&tid=136332

此帖就关闭处理了
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部