找回密码
 立即注册

QQ登录

只需一步,快速开始

宛若无垠

注册会员

1

主题

9

帖子

18

积分

注册会员

积分
18
  • 64

    金币

  • 1

    主题

  • 9

    帖子

最新发帖
宛若无垠
注册会员   /  发表于:2021-10-17 15:13  /   查看:3404  /  回复:14
本帖最后由 Derrick.Jiao 于 2021-10-20 17:08 编辑

使用setCellType后下拉功能点击无效

const newCellType = cursorCellTypeCreator(msgCellType)
          newCellType.userList.unshift({
            userId: msg.userId,
            userName: msg.userNick,
            color: configer.userFlagColor[otherUserList[i].rainbowIndex]
          })
          sheet.setCellType(row, col, newCellType)

再次点击下拉后就无效了,需要双击把单元格改变到编辑状态,才能去点击下拉

image.png954711608.png


14 个回复

倒序浏览
Derrick.Jiao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2021-10-20 17:09:29
推荐
你好,请参考附件的demo,修改getHitInfo里面的代码

test (1).html

8.41 KB, 下载次数: 141

回复 使用道具 举报
Derrick.Jiao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2021-10-18 09:50:13
沙发
你好,请问你使用的版本是多少呢?请把完整能复现问题的代码以及demo提供一下,这边调研一下。另外,这边也提供一个demo,也可以在上面复现你的问题。

data.html

1.69 KB, 下载次数: 87

回复 使用道具 举报
宛若无垠
注册会员   /  发表于:2021-10-18 16:59:45
板凳
Derrick.Jiao 发表于 2021-10-18 09:50
你好,请问你使用的版本是多少呢?请把完整能复现问题的代码以及demo提供一下,这边调研一下。另外,这边也 ...

你好,我使用咱们的提供的也是这样子,麻烦给看下,谢谢,是不是哪里写的有问题
回复 使用道具 举报
宛若无垠
注册会员   /  发表于:2021-10-18 17:03:13
地板
本帖最后由 宛若无垠 于 2021-10-18 17:04 编辑
  1. <head>
  2.     <meta charset="UTF-8" />
  3.     <link
  4.         rel="stylesheet" type="text/css" />

  5.     <script src="http://cdn.grapecity.com/spreadjs/hosted/scripts/gc.spread.sheets.all.14.1.6.min.js"></script>
  6.     <script src="http://cdn.grapecity.com/spreadjs/hosted/scripts/interop/gc.spread.excelio.14.1.6.min.js"></script>
  7.     <script src="https://cdn.grapecity.com.cn/spreadjs/scripts/jquery-1.11.1.min.js" type="text/javascript"></script>

  8.     <style>
  9.         .sample-tutorial {
  10.             position: relative;
  11.             height: 100%;
  12.             overflow: hidden;
  13.         }

  14.         .sample-spreadsheets {
  15.             width: calc(100% - 280px);
  16.             height: 100%;
  17.             overflow: hidden;
  18.             float: left;
  19.             position: relative;
  20.         }
  21.     </style>
  22. </head>

  23. <body>

  24.     <div id="ss" class="sample-spreadsheets"></div>


  25.     <script>

  26.         var spreadNS = GC.Spread.Sheets;

  27.         $(document).ready(function () {
  28.             var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), { sheetCount: 3 });

  29.             var sheet = spread.getActiveSheet();
  30.             spread['ExcelClient'] = {}
  31.             spread['ExcelClient'].otherUserList = [
  32.                 {
  33.                     "userId": "1312312312",
  34.                     "selectList": [
  35.                         {
  36.                             "sheetName": "Sheet1",
  37.                             "row": 0,
  38.                             "col": 1
  39.                         }
  40.                     ],
  41.                     "rainbowIndex": 2
  42.                 }
  43.             ]

  44.             var combo = new spreadNS.CellTypes.ComboBox();
  45.             combo.items([{ text: "Oranges", value: "11k" }, { text: "Apples", value: "15k" }, { text: "Grape", value: "100k" }])
  46.                 .editorValueType(spreadNS.CellTypes.EditorValueType.text);
  47.             sheet.getCell(1, 2, spreadNS.SheetArea.viewport).cellType(combo).value("Apples");
  48.             sheet.setValue(1, 1, "ComboBoxCellType");
  49.             const msgCellType = sheet.getCellType(1, 2)
  50.             const newCellType = cursorCellTypeCreator(msgCellType)
  51.             sheet.setCellType(1, 2, newCellType)
  52.             setTimeout(()=>{
  53.                 let msg = {
  54.                     "sheetIndex": 0,
  55.                     "sheetName": "Sheet1",
  56.                     "userId": "1231231231321",
  57.                     "userNick": "王**",
  58.                     "range": {
  59.                         "row": Math.floor(Math.random() * 10),
  60.                         "rowCount": 1,
  61.                         "col": Math.floor(Math.random() * 10),
  62.                         "colCount": 1
  63.                     },
  64.                     "type": "changeSelection",
  65.                     "msgId": "1231312313123",
  66.                     "agentFlag": "1231313213"
  67.                 }
  68.                 updateOtherSelection(msg,spread)
  69.             },2000)
  70.         });

  71.         


  72. // 协作者光标单元格类型
  73. function cursorCellTypeCreator(cellType){
  74.     if (cellType.typeName === 'CursorCellType') {
  75.     return cellType
  76.   }
  77.   class CursorCellType extends cellType.constructor {
  78.     getHitInfo(x, y, cellStyle, cellRect, context) {
  79.       const info = { x: x, y: y, row: context.row, col: context.col, cellRect: cellRect, sheetArea: context.sheetArea }
  80.       return info
  81.     }
  82.     processMouseEnter(hitInfo) {
  83.       this.showName = true
  84.       hitInfo.sheet.repaint()
  85.     }
  86.     processMouseLeave(hitInfo) {
  87.       this.showName = false
  88.       hitInfo.sheet.repaint()
  89.     }
  90.     paint(ctx, value, x, y, w, h, style, context) {
  91.       if (ctx) {
  92.         ctx.save()
  93.         super.paint.apply(this, [ctx, value, x, y, w, h, style, context])
  94.         // 绘制单元格矩形框开始
  95.         ctx.strokeStyle = 'orange'
  96.         ctx.lineWidth = 2
  97.         ctx.strokeRect(x + 2, y + 2, w - 4, h - 4)
  98.         if (this.showName) {
  99.         ctx.fillStyle = 'red'
  100.         ctx.font = '14px Arial'
  101.         const textWidth = parseInt(ctx.measureText('hover效果').width) // 获取文字要占据的宽度
  102.         const paintY = context.row === 0 ? y + h + 20 : y
  103.         ctx.fillRect(x + w - (textWidth + 10), paintY - 20, textWidth + 10, 20)
  104.         ctx.fillStyle = 'white'
  105.         ctx.fillText('hover效果', x + w - 5, paintY - 5)
  106.         }
  107.         ctx.restore()
  108.       }
  109.     }
  110.   }
  111.   const newCellType = new CursorCellType()
  112.   Object.assign(newCellType, cellType)
  113.   return newCellType
  114. }


  115. // 处理协作者光标变化
  116. function updateOtherSelection(msg, spread) {
  117.   const sheet = spread.getSheetFromName(msg.sheetName)
  118.   if (sheet) {
  119.     const row = msg.range.row < 0 ? 0 : msg.range.row
  120.     const col = msg.range.col < 0 ? 0 : msg.range.col
  121.     const otherUserList = spread.ExcelClient.otherUserList || []
  122.     for (let i = 0; i < otherUserList.length; i++) {
  123.       if (otherUserList[i].userId === msg.userId) {
  124.         let oldCellType
  125.         for (let j = 0; j < otherUserList[i].selectList.length; j++) {
  126.           // 清除光标数据&清除光标单元格
  127.           if (otherUserList[i].selectList[j].sheetName === msg.sheetName) {
  128.             oldCellType = sheet.getCellType(otherUserList[i].selectList[j].row, otherUserList[i].selectList[j].col)
  129.             if (oldCellType.typeName === 'CursorCellType') {
  130.               for (let k = 0; k < oldCellType.userList.length; k++) {
  131.                 if (oldCellType.userList[k].userId === msg.userId) {
  132.                   oldCellType.userList.splice(k, 1)
  133.                   sheet.repaint(sheet.getCellRect(otherUserList[i].selectList[j].row, otherUserList[i].selectList[j].col, 1, 1))
  134.                   break
  135.                 }
  136.               }
  137.             }
  138.             // 设置新的光标数据
  139.             otherUserList[i].selectList[j].row = row
  140.             otherUserList[i].selectList[j].col = col
  141.             break
  142.           }
  143.         }
  144.         // 设置新的光标数据
  145.         if (!oldCellType) {
  146.           otherUserList[i].selectList.push({sheetName: msg.sheetName, row: row, col: col})
  147.         }
  148.         // 设置新的光标单元格
  149.         const msgCellType = sheet.getCellType(row, col)
  150.         if (msgCellType.typeName === 'CursorCellType') {
  151.           for (let m = 0; m < msgCellType.userList.length; m++) {
  152.             if (msgCellType.userList[m].userId === msg.userId) {
  153.               msgCellType.userList.splice(m, 1)
  154.               break
  155.             }
  156.           }
  157.         sheet.repaint(sheet.getCellRect(row, col, 1, 1))
  158.         } else {
  159.           const newCellType = cursorCellTypeCreator(msgCellType)
  160.           sheet.setCellType(row, col, newCellType)
  161.         }
  162.         break
  163.       }
  164.     }
  165.   }
  166. }





  167.     </script>
  168. </body>

  169. </html>
复制代码
回复 使用道具 举报
宛若无垠
注册会员   /  发表于:2021-10-18 17:12:12
5#
初步判断是getHitInfo导致的,但是具体bug在哪里不太清楚,麻烦给看下,谢谢
回复 使用道具 举报
Derrick.Jiao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2021-10-18 18:22:22
6#
宛若无垠 发表于 2021-10-18 17:12
初步判断是getHitInfo导致的,但是具体bug在哪里不太清楚,麻烦给看下,谢谢

问题已收到,这边需要做进一步调研,此贴为你改为保留处理,有进展会在本帖更新。
回复 使用道具 举报
宛若无垠
注册会员   /  发表于:2021-10-18 18:30:31
7#
Derrick.Jiao 发表于 2021-10-18 18:22
问题已收到,这边需要做进一步调研,此贴为你改为保留处理,有进展会在本帖更新。

谢谢,感激不尽
回复 使用道具 举报
Derrick.Jiao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2021-10-18 18:39:24
8#

客气,这边有进展也会在本帖更新。
回复 使用道具 举报
宛若无垠
注册会员   /  发表于:2021-10-19 17:24:36
9#
Derrick.Jiao 发表于 2021-10-18 18:39
客气,这边有进展也会在本帖更新。

大佬怎么样了,有啥进度不
回复 使用道具 举报
Derrick.Jiao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2021-10-19 18:01:29
10#
宛若无垠 发表于 2021-10-19 17:24
大佬怎么样了,有啥进度不

暂时还没有哈,我们这边新版本的研发、bug修复和问题的处理是同步进行的。会根据优先级进行安排查看的。有进展这边也会更新。你也可以关注我们的公众号:葡萄城社区,有回复了也会推送。
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部