找回密码
 立即注册

QQ登录

只需一步,快速开始

tiansfather

注册会员

13

主题

34

帖子

135

积分

注册会员

积分
135
tiansfather
注册会员   /  发表于:2020-8-27 08:35  /   查看:2170  /  回复:4
本帖最后由 tiansfather 于 2020-8-27 08:46 编辑

var AutocompleteCellType =function(){}
AutocompleteCellType .prototype=new GC.Spread.Sheets.CellTypes.Base();

AutocompleteCellType .prototype.deactivateEditor=fn
> 我用的vue的element的组件
createEditorElement() {
    let input = document.createElement("input");
    input.id = "Autocomplete" + Vue.prototype.$$.newid();
    return input;
  }
  handleInput() {
    console.log(arguments);
  }
  activateEditor(editorContext) {
    this.vm = new ColReferenceIns({
      propsData: {
        column: this.column,
        value: "",
        handleInput: this.handleInput,
      },
    }).$mount(editorContext);
  }
  deactivateEditor(editorContext, context) {
    console.log(this.vm.$destroy);
    this.vm.$destroy();
    spreadNS.CellTypes.Base.prototype.deactivateEditor.call(this, editorContext, context);
  }

-----------------------------------

这个deactivateEditor的触发时机什么时候

如图所见,我无法销毁这个select,这个console.log也不会触发


示例可见 http://jsrun.net/BELKp/edit 的js部分
QQ图片20200827083226.png

4 个回复

倒序浏览
Lynn.Dou讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2020-8-27 10:19:13
沙发
在您选择下拉列表的选项之后,点击此单元格以外的区域,触发deactivateEditor。

您可以参考以下链接:
https://demo.grapecity.com.cn/Sp ... s/autoComplete.html

请问您具体的需求是什么呢?
回复 使用道具 举报
tiansfather
注册会员   /  发表于:2020-8-27 13:52:26
板凳
我想要,在input失去焦点时候就结束并触发deactivateEditor。
现在deactivateEditor一直触发不了
回复 使用道具 举报
tiansfather
注册会员   /  发表于:2020-8-27 14:03:52
地板
没事我知道原因了,因为原来return 回去的editorContext被我使用vue给替换了,vue在实例化过程中会将传递给el的元素替换成新创建的dom。在createEditorElement的时候return的wrap的引用估计被spread内部用来监听失焦事件。vue把他wrap替换了导致内部的引用失效。我把他改成两层dom结构,vue依赖的是子节点
  1. createEditorElement() {
  2.     let wrap = document.createElement("div");
  3.     let input = document.createElement("input");
  4.     input.id = "Autocomplete" + Vue.prototype.$.newid();
  5.     wrap.appendChild(input);
  6.     return wrap;
  7.   }
复制代码
回复 使用道具 举报
Lynn.Dou讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2020-8-27 14:43:21
5#

解决了就好~
那就结帖啦,有问题可以另开新帖。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部