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

QQ登录

只需一步,快速开始

Dtttax

银牌会员

274

主题

680

帖子

2182

积分

银牌会员

积分
2182
Dtttax
银牌会员   /  发表于:2025-1-17 16:25  /   查看:101  /  回复:3
1金币




spreadjs 有没有单元格这种多选的单元格。
image.png928819580.png

最佳答案

查看完整内容

您好!下拉框可以支持多选,如果您通过Style设置了下拉框,需要戒指multiSelect属性支持下拉框多选。此外,还可以自定义单元格实现。您可以参考如下论坛博客了解上述两种支持方法的设置详情: https://gcdn.grapecity.com.cn/showtopic-225648.html

3 个回复

倒序浏览
最佳答案
最佳答案
Wilson.Zhang
超级版主   /  发表于:2025-1-17 16:25:58
来自 2#
您好!下拉框可以支持多选,如果您通过Style设置了下拉框,需要戒指multiSelect属性支持下拉框多选。此外,还可以自定义单元格实现。您可以参考如下论坛博客了解上述两种支持方法的设置详情:
https://gcdn.grapecity.com.cn/showtopic-225648.html
回复 使用道具 举报
Dtttax
银牌会员   /  发表于:2025-1-21 17:44:18
3#
有个问题,vue3里面自定义的下拉框不行。始终不认识自定义的autocomplete控件。在vue2就可以。

import $ from 'jquery';
import   'jquery-ui'
cell.cellType(new AutocompleteCellType())
function AutocompleteCellType(noteIndex, typeKey, typeName, data) {
  this.usedForImport = null
  if (typeName) {
    this.typeName = typeName
  } else {
    this.typeName = 'AutocompleteCellType'
  }

  this.typeKey = typeKey
  this.noteIndex = noteIndex
  this.sourceData = data
}
AutocompleteCellType.prototype = new GC.Spread.Sheets.CellTypes.Base()
AutocompleteCellType.prototype.createEditorElement = function (context) {
  return document.createElement('input')
}
AutocompleteCellType.prototype.activateEditor = function (
  editorContext,
  cellStyle,
  cellRect,
  context
) {
  var $editor = $(editorContext)
  console.log($editor)
  GC.Spread.Sheets.CellTypes.Base.prototype.activateEditor.call(
    this,
    editorContext,
    cellStyle,
    cellRect,
    context
  )
  $editor.css('position', 'absolute')
  $editor.css('font', cellStyle.font)
  $editor.css('color', cellStyle.foreColor)
  //$editor.css("border-bottom", "none");
  //$editor.css("border-left", "1px solid white");
  //$editor.css("border-top", "1px solid white");
  $editor.css('border', 'none')
  $editor.attr('gcUIElement', 'gcEditingInput')
  let tagData = null
  if (this.sourceData && this.sourceData.length > 0) {
    tagData = this.sourceData
  } else {
    tagData =["test","test1"]
  }
  let activeRow = context.sheet.getActiveRowIndex()
  let activeCol = context.sheet.getActiveColumnIndex()
  let cell = context.sheet.getCell(activeRow, activeCol)
  let that = this
  $editor
    .autocomplete({
      minLength: 0,
      source: tagData,
      matchContains: true,
      select: function (event, ui) {
        if (!that.typeKey && that.typeName === 'AutocompleteCellType') {
          let cellInfo = { cell: cell, taxonamyId: ui.item.id }
          if (that.noteIndex != undefined) {
            onBreakdownAutocompleteValueChanged(context.sheet, [cellInfo])
          } else {
            // setCellReturnTag(ui.item.id,activeRow);
            //  cell.value(ui.item.label)
            onShowTagCellValueChanged(context.sheet, [cellInfo])
          }
        }
      },
    })
    .focus(function () {
      if ($(this).val()) {
        $(this).autocomplete('search', $(this).val().trim())
      } else {
        $(this).autocomplete('search', $(this).val())
      }
    })
    .change()
  $editor.data('ui-autocomplete')._renderItem = function (ul, item) {
    return $('<li>')
      .append("<div title='" + item.desc + "'>" + item.label + '</div>')
      .appendTo(ul)
  }
  let autocompleteStyle =
    'max-height: 300px;overflow-y:scroll;overflow-x:hidden;'
  if (this.usedForImport) {
    autocompleteStyle = 'max-height: 300px;overflow-y:scroll;overflow-x:hidden;'
  }
  $editor.autocomplete('widget').attr('style', autocompleteStyle)
  $editor.autocomplete('widget').attr('gcUIElement', 'gcEditingInput') // keep focus when mouse down on dropdown
  if ($editor.val() == '') {
    $editor.autocomplete('search', '')
  }
  return $editor
}
AutocompleteCellType.prototype.deactivateEditor = function (
  editorContext,
  context
) {
  if (editorContext) {
    var $editor = $(editorContext)
    // $editor.autocomplete("hide");
    $editor.autocomplete('destroy')
  }
  GC.Spread.Sheets.CellTypes.Base.prototype.deactivateEditor.call(
    this,
    editorContext,
    context
  )
}
AutocompleteCellType.prototype.setEditorValue = function (
  editorContext,
  value,
  context
) {
  $(editorContext).val(value)
}
AutocompleteCellType.prototype.getEditorValue = function (
  editorContext,
  context
) {
  return $(editorContext).val()
}
AutocompleteCellType.prototype.updateEditor = function (
  editorContext,
  cellStyle,
  cellRect,
  context
) {
  if (editorContext) {
    var $editor = $(editorContext)
    $editor.css('width', cellRect.width)
    $editor.css('height', cellRect.height)
  }
}
AutocompleteCellType.prototype.isReservedKey = function (event, context) {
  if (context.isEditing && (event.keyCode == 40 || event.keyCode == 38)) {
    return true
  }
  return false
}
回复 使用道具 举报
Wilson.Zhang
超级版主   /  发表于:2025-1-22 09:41:05
4#
Dtttax 发表于 2025-1-21 17:44
有个问题,vue3里面自定义的下拉框不行。始终不认识自定义的autocomplete控件。在vue2就可以。

import $ ...

发现您在论坛就该问题发布了新帖子,那就在新贴中跟进讨论您的问题:
https://gcdn.grapecity.com.cn/forum.php?mod=viewthread&tid=232824

既然在本帖咨询新问题,那理解本贴原始问题已得到解决,那就结帖了。如有新问题,欢迎发新帖沟通。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部