草庐IT

javascript - ExtJS 6 : Issue using multiple editors in a single grid column

coder 2024-07-26 原文

笔记

ExtJS 版本:6.2.1.167

fiddle :fiddle.sencha.com/#view/editor&fiddle/1tlt

此功能在 ExtJS 2.x 中有效,没有任何问题。

目标

拥有一个网格(具有分组功能和单元格编辑插件),它可以在单个列中包含多个不同的编辑器(textfieldcombo s)。

网格颠倒了传统的表格系统,使字段名称和记录值垂直显示。此处显示了表头的示例:

+-------------+-----------------+-----------------+-----------------
- Field Names - Record 1 Values - Record 2 Values - Editable Column
+-------------+-----------------+-----------------+-----------------

我们不能使用传统的系统,因为有数百个字段,但只有几条记录可以比较。

代码

Here is the fiddle

这是允许我使用多个编辑器的主要代码:

Ext.define('MemberCellEditing', {

  extend: 'Ext.grid.plugin.CellEditing',
  xtype: 'membercellediting',
  alias: 'plugin.membercellediting',

  getCachedEditor: function(editorId, record, column) {
    var me = this,
      editors = me.editors,
      dropDownName = record.get('dropDown');

    // If dropdown field, use dropdown name as editor id
    if (dropDownName && dropDownName != 'N') editorId = dropDownName;

    // Attempt to get editor
    var editor = editors.getByKey(editorId);

    if (!editor) {

      if (dropDownName && dropDownName != 'N') {
        // Retrieve combo
        var combo = DropDownManager.getCombo(editorId);

        // Create editor with combo
        editor = Ext.create('Ext.grid.CellEditor', {
          editorId: editorId, // Each dropdown field will have its own combo
          field: combo,
          floating: true
        });
      } else {
        // Use default editor configured for column
        editor = column.getEditor(record);
      }

      if (!editor) {
        return false;
      }

      // Allow them to specify a CellEditor in the Column
      if (!(editor instanceof Ext.grid.CellEditor)) {
        // Apply the field's editorCfg to the CellEditor config.
        // See Editor#createColumnField. A Column's editor config may
        // be used to specify the CellEditor config if it contains a field property.
        editor = new Ext.grid.CellEditor(Ext.apply({
          floating: true,
          editorId: editorId,
          field: editor
        }, editor.editorCfg));
      }

      // Add the Editor as a floating child of the grid
      // Prevent this field from being included in an Ext.form.Basic
      // collection, if the grid happens to be used inside a form
      editor.field.excludeForm = true;

      // If the editor is new to this grid, then add it to the grid, and ensure it tells us about its life cycle.
      if (editor.column !== column) {
        editor.column = column;
        column.on('removed', me.onColumnRemoved, me);
      }
      editors.add(editor);
    }

    // Inject an upward link to its owning grid even though it is not an added child.
    editor.ownerCmp = me.grid.ownerGrid;

    if (column.isTreeColumn) {
      editor.isForTree = column.isTreeColumn;
      editor.addCls(Ext.baseCSSPrefix + 'tree-cell-editor');
    }

    // Set the owning grid.
    // This needs to be kept up to date because in a Lockable assembly, an editor
    // needs to swap sides if the column is moved across.
    editor.setGrid(me.grid);

    // Keep upward pointer correct for each use - editors are shared between locking sides
    editor.editingPlugin = me;
    return editor;
  }
});



问题

虽然我当前的代码将成功地让您在单个列中使用多个编辑器,但它“随机”抛出错误。我随机说是因为我无法追踪错误的实际原因。

错误 #1
无法获得属性(property)style未定义或空引用

screenshot



错误 #2
无法获得属性(property)parentNode未定义或空引用

screenshot



这两个错误的原因是因为 el当前引用的编辑器上的属性已被破坏,这意味着没有 dom属性(property)。

如何复制

这是我无法解决此问题的部分原因。我还没有找到复制问题的具体方法。不幸的是,我得到错误的方式是单击/切换到单元格、输入数据、切换到其他单元格、切换组等的随机组合......我目前通常有效的方法包括输入一些随机数据,然后疯狂点击在两个相邻单元格之间交替聚焦。大多数情况下,得到错误的时间不到 30 秒。

我目前的理论是,有一个事件被触发,它调用了一些函数,无论出于何种原因,它都会破坏编辑器的 el。属性(property)。我尝试查看错误调用堆栈顶部的值,似乎 el在那一点上,属性(property)已经被破坏了。

底线

我正在寻找有关如何追踪问题的实际原因的建议。

更新

事实证明,目前在单元格编辑器中使用组合存在一个错误。这是另一个有非常相似问题的人:

https://www.sencha.com/forum/showthread.php?330959-ExtJs-6-2-CellEditing-plugin-editor-el-dom-is-null

这是错误 ID:EXTJS-23330

根据 Sencha Support 的说法,目前没有可用的解决方法,并且该错误仍然存​​在。

更新#2

此错误存在于 6.0.2 和 6.5 中。

幸运的是,我找到了一种更一致地重现该错误的方法:
  • 将鼠标悬停在 A 组上 5 秒。展开A组。
  • 将鼠标悬停在(字段 1,值列)上 5 秒。
  • 单击(字段 1,值列)。
  • 等待 5 秒,然后折叠 A 组。
  • 等待 3 秒,然后将鼠标悬停在 B 组标题上。
  • 等待 10 秒,然后将鼠标悬停在 A 组标题上。
  • 等待 3 秒,然后展开 A 组。
  • 将鼠标悬停在(字段 1,值列)字段上 3 秒。
  • 将鼠标悬停在(字段 1,值 2 列)上 3 秒。
  • 单击(字段 1,值 2 列)。

  • 如果错误没有发生(在 6.5 中似乎还没有发生):
  • 等待 3 秒,然后单击(字段 1,值列)。
  • 等待 1 秒,然后再次单击(字段 1,值列)。

  • 它不是 100%,但比随机点击要可靠得多。

    最佳答案

    如果没有代码和调用堆栈中的更多上下文,很难判断,但如果上面的错误 #2 仍然是手头问题的一个很好的例子,您应该能够更改 !editor.rendered 检查的 else 以读取 else if (!editor.destroyed) ,屏幕截图中断点的正上方。

    关于javascript - ExtJS 6 : Issue using multiple editors in a single grid column,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43284673/

    有关javascript - ExtJS 6 : Issue using multiple editors in a single grid column的更多相关文章

    1. ruby-on-rails - 使用 javascript 更改数据方法不会更改 ajax 调用用户的什么方法? - 2

      我遇到了一个非常奇怪的问题,我很难解决。在我看来,我有一个与data-remote="true"和data-method="delete"的链接。当我单击该链接时,我可以看到对我的Rails服务器的DELETE请求。返回的JS代码会更改此链接的属性,其中包括href和data-method。再次单击此链接后,我的服务器收到了对新href的请求,但使用的是旧的data-method,即使我已将其从DELETE到POST(它仍然发送一个DELETE请求)。但是,如果我刷新页面,HTML与"new"HTML相同(随返回的JS发生变化),但它实际上发送了正确的请求类型。这就是这个问题令我困惑的

    2. ruby - 在 Mechanize 中使用 JavaScript 单击链接 - 2

      我有这个:AccountSummary我想单击该链接,但在使用link_to时出现错误。我试过:bot.click(page.link_with(:href=>/menu_home/))bot.click(page.link_with(:class=>'top_level_active'))bot.click(page.link_with(:href=>/AccountSummary/))我得到的错误是:NoMethodError:nil:NilClass的未定义方法“[]” 最佳答案 那是一个javascript链接。Mechan

    3. javascript - jQuery 的 jquery-1.10.2.min.map 正在触发 404(未找到) - 2

      我看到有关未找到文件min.map的错误消息:GETjQuery'sjquery-1.10.2.min.mapistriggeringa404(NotFound)截图这是从哪里来的? 最佳答案 如果ChromeDevTools报告.map文件的404(可能是jquery-1.10.2.min.map、jquery.min.map或jquery-2.0.3.min.map,但任何事情都可能发生)首先要知道的是,这仅在使用DevTools时才会请求。您的用户不会遇到此404。现在您可以修复此问题或禁用sourcemap功能。修复:获取文

    4. ruby-on-rails - 我将 Rails3 与 tinymce 一起使用。如何呈现用户关闭浏览器javascript然后输入xss? - 2

      我有一个用Rails3编写的站点。我的帖子模型有一个名为“内容”的文本列。在帖子面板中,html表单使用tinymce将“content”列设置为textarea字段。在首页,因为使用了tinymce,post.html.erb的代码需要用这样的原始方法来实现。.好的,现在如果我关闭浏览器javascript,这个文本区域可以在没有tinymce的情况下输入,也许用户会输入任何xss,比如alert('xss');.我的前台会显示那个警告框。我尝试sanitize(@post.content)在posts_controller中,但sanitize方法将相互过滤tinymce样式。例如

    5. ruby - 使用 Selenium WebDriver 启用/禁用 javascript - 2

      出于某种原因,我必须为Firefox禁用javascript(手动,我们按照提到的步骤执行http://support.mozilla.org/en-US/kb/javascript-settings-for-interactive-web-pages#w_enabling-and-disabling-javascript)。使用Ruby的SeleniumWebDriver如何实现这一点? 最佳答案 是的,这是可能的。而是另一种方式。您首先需要查看链接Selenium::WebDriver::Firefox::Profile#[]=

    6. ruby - Watir-Webdriver 是否支持点击目标为 javascript 的链接? - 2

      我是Ruby和Watir-Webdriver的新手。我有一套用VBScript编写的站点自动化程序,我想将其转换为Ruby/Watir,因为我现在必须支持Firefox。我发现我真的很喜欢Ruby,而且我正在研究Watir,但我已经花了一周时间试图让Webdriver显示我的登录屏幕。该站点以带有“我同意”区域的“警告屏幕”开头。用户点击我同意并显示登录屏幕。我需要单击该区域以显示登录屏幕(这是同一页面,实际上是一个表单,只是隐藏了)。我整天都在用VBScript这样做:objExplorer.Document.GetElementsByTagName("area")(0).click

    7. 网页设计期末作业,基于HTML+CSS+JavaScript超酷超炫的汽车类企业网站(6页) - 2

      🎉精彩专栏推荐💭文末获取联系✍️作者简介:一个热爱把逻辑思维转变为代码的技术博主💂作者主页:【主页——🚀获取更多优质源码】🎓web前端期末大作业:【📚毕设项目精品实战案例(1000套)】🧡程序员有趣的告白方式:【💌HTML七夕情人节表白网页制作(110套)】🌎超炫酷的Echarts大屏可视化源码:【🔰Echarts大屏展示大数据平台可视化(150套)】🔖HTML+CSS+JS实例代码:【🗂️5000套HTML+CSS+JS实例代码(炫酷代码)继续更新中…】🎁免费且实用的WEB前端学习指南:【📂web前端零基础到高级学习视频教程120G干货分享】🥇关于作者:💬历任研发工程师,技术组长,教学总监;

    8. ruby-on-rails - 在页面的最底部包含 javascript 文件 - 2

      我有一个Rails应用程序。还有一个javascript(javascript1.js)文件必须包含在每个View的最底部。我把它放在/assets/javascripts文件夹中。Application.js包含以下代码//=requirejquery//=requirejquery_ujs//=someotherfiles//=require_directory.即使Application.js中不包含javascript1.js,它也会自动包含,不是吗?那么我怎样才能做我想做的事呢? 最佳答案 单独定义、包含和执行您的java

    9. ruby-on-rails - 为 rails 中的 javascript 生成完整的 url(类似于 javascript_path,但是是 url) - 2

      如何生成指向javascript文件的绝对链接。我想应该有类似下面的东西(不幸的是它似乎不可用):javascript_url'main'#->'http://localhost:3000/javascripts/main.js'代替:javascript_path'main'#->'/javascripts/main.js'我需要绝对URL,因为该javascript文件将用于书签。另外我需要相同的css文件。谢谢,德米特里。 最佳答案 javascript和css文件的绝对URL现在在Rails4中可用ActionView::H

    10. ruby - 处理在 keyup 事件上发生的 javascript 弹出窗口 - 2

      我在HTML页面上有一个文本字段,用于检查您是否输入了1到365之间的值。如果用户输入了无效值,如非数字字符或不在范围内的值,它显示一个弹出窗口。我在watirwiki上看到有一个select_no_wait方法,用于在您从列表中选择无效值时关闭弹出窗口。处理键盘事件时出现的弹出窗口的好方法是什么?我是否需要按照select_no_wait方法的实现方式进行操作,或者我们是否可以启动一个不同的进程来消除调用set方法时可能出现的弹出窗口。带有Javascript验证函数的HTML文件示例如下:varnum=0functionvalidate(e){varcharPressed=Stri

    随机推荐