angular-slickgrid - Angular-Slickgrid Select 或 Multiselect 下拉菜单在第一次单击时闪烁(自动关闭)
问题描述
以下是我正在使用的代码
1.我在 angular slickgrid 表中添加了一个新行,代码如下 const newItem = { id: this.dataset.length + this.index, roleName: '' };
// add the item to the grid
this.angularGrid.gridService.addItem(newItem);
- 以下是列定义
this.columnDefinitions = [ { id: 'roleName', name: 'Role *', field: 'roleName', sortable: true, type: FieldType.string, filterable: true, width: 80, editor: { model: Editors. singleSelect, enableRenderHtml: true, collection: ['1','2', '3'], placeholder: '选择一个选项', collectionSortBy: { property: 'label' }, } } ]
3.GridOptions有:
this.gridOptions = { enableAutoResize: true,
enableCellNavigation: true, editable: true, autoEdit: true, enableColumnPicker: true, };
但是可以看到当我在表中添加新行并且如果我快速单击选择元素然后它会在几秒钟内打开一个下拉列表然后它会自动关闭。
解决方案
请注意,我是 Angular-Slickgrid 的作者,我已经回复了您在此处为相同问题打开的 GitHub 问题。答案将与下图相同
发生这种情况是因为您使用的是addItem
来自网格服务的,它突出显示插入的行 1.5 秒,它通过向该行添加一个 css 类 1.5 秒然后在突出显示结束后将其删除(有一个额外的 css动画),当它这样做时,它将从任何打开的编辑器中移除焦点。真正的原因是,一旦突出显示它,在 1.5 秒后,它会调用网格的重新渲染(通过invalidate
),并且因为它重新渲染了整行,所以它会删除编辑器。
因此,如果您不喜欢这种行为,那么您可以通过以下选项简单地删除突出显示
this.angularGrid.gridService.addItem(newRows[0], { highlightRow: false });
推荐阅读
- scala - 在 Databricks 中运行对象笔记本
- python - 如何使用 Selenium 使用我的书签和设置打开浏览器实例?
- azure - 在 Synapse Analytics 上优化 Azure 分析服务处理
- powershell - 无法将 SharePoint (PnP) 连接传递到 PowerShell 作业,因为它正在反序列化?
- angular - Angular:如果没有输入,则不显示 HTML 属性
- java - Jsoup Login in to website仅返回html的头部
- mysql - 在不使用子查询的情况下为 CREATE VIEW 重新构造查询?
- sql - 用“-”分隔列(用于 xml 路径)
- powershell - 使用 PowerShell 解析 Win32 可执行输出
- pandas - 在df python中动态创建列