- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在创建一个 extjs 网格面板,它有一组用户可配置的列。 Ext.grid.Panel
组件为此目的提供了一个方便的 reconfigure(store, columns)
方法。
此方法可按预期重新配置网格的存储/列,而无需完全销毁并重新创建网格。但是,如果您使用的是 Ext.grid.plugins.RowEditing
提供内联行编辑的插件,在使用新列重新配置网格后,列不同步。
这尤其令人沮丧,因为 RowEditing 插件已经监视添加/删除/调整列的大小并正确处理这些列。我怀疑这只是对当前 ExtJs 4.1 版本的疏忽。
我想要的是,当使用新列重新配置网格时,RowEditor 更新其编辑器列表和宽度,而不破坏/重新创建网格/ View 。
经过多次谷歌搜索后,似乎我并不是唯一一个在寻找具有内联编辑支持的易于重新配置的列列表的人。
最佳答案
Ext.grid.Panel
提供一个“重新配置”事件,该事件在调用 reconfigure()
方法后随时触发。但是,在当前的 ExtJs 4.1 版本中,RowEditing 插件没有挂接到此事件!
看来我们需要自己做繁重的工作。最终的解决方案相当简单,尽管花了几个小时才得出最终代码。
RowEditing 插件创建 RowEditor 组件的一个实例(明白了吗?请记住这两者是分开的,相似的名称但不同的组件!)。 RowEditing 插件与网格相关联,它连接到必要的事件中以了解何时显示行编辑器等。RowEditor 是可视化组件,它会在您的行上方弹出,以便在网格中进行内联编辑。
起初我尝试重新配置行编辑器可能有十几种不同的方法。我尝试调用内部方法、初始化方法、调整大小方法等……然后我注意到该体系结构的一些优点。有一个对 RowEditor 实例的内部引用,其中包含获取行编辑器和延迟加载(如果需要)的方法。这是关键!
您可以在不破坏 RowEditing 插件的情况下破坏 RowEditor(您不能动态加载/卸载插件),然后重新创建 RowEditor。
还有一个问题,即 Ext 网格的编辑插件为 getEditor()
和 setEditor()
的每一列添加了一些扩展方法,它们是用于为每一列获取/设置正确的编辑器类型。当您重新配置网格时,任何应用的扩展方法都“消失”了(好吧,您有一些从未应用过这些方法的新列)。因此,您还需要通过调用插件上的 initFieldAccessors()
方法来重新应用这些访问器方法。
这是我对网格面板的重新配置事件的处理程序:
/**
* @event reconfigure
* Fires after a reconfigure.
* @param {Ext.grid.Panel} this
* @param {Ext.data.Store} store The store that was passed to the {@link #method-reconfigure} method
* @param {Object[]} columns The column configs that were passed to the {@link #method-reconfigure} method
*/
onReconfigure: function (grid, store, columnConfigs) {
var columns = grid.headerCt.getGridColumns(),
rowEditingPlugin = grid.getPlugin('rowEditor');
//
// Re-attached the 'getField' and 'setField' extension methods to each column
//
rowEditingPlugin.initFieldAccessors(columns);
//
// Re-create the actual editor (the UI component within the 'RowEditing' plugin itself)
//
// 1. Destroy and make sure we aren't holding a reference to it.
//
Ext.destroy(rowEditingPlugin.editor);
rowEditingPlugin.editor = null;
//
// 2. This method has some lazy load logic built into it and will initialize a new row editor.
//
rowEditingPlugin.getEditor();
}
我使用配置监听器将其附加到我的网格面板中:
listeners: {
'reconfigure': Ext.bind(this.onReconfigure, this)
}
关于javascript - 使用 Ext.grid.Panel.reconfigure() 打破网格 RowEditing 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11963870/
这似乎是一个基本问题,但我已经尝试了一段时间并没有找到 Pyviz Panel 的解决方案: 我试图通过单击按钮来触发函数,捕捉函数的输出并将它们打印在屏幕上所需的位置。 with output ip
我正在尝试在销售订单屏幕上创建一个智能面板,它将显示与 SOLine 库存项目相关的项目。 我在库存项目页面上添加了一个选项卡和网格,并使用 CFBSUPSale 的 DAC 创建了一个表来创建此关系
需要这个: 但是得到这个: 我需要自定义绘制矩形来执行上述操作吗?另外我需要在面板内显示一个数字。有什么想法可以解决这个问题吗? 最佳答案 不要将第三个面板(水平面板)放在其他面板之一内。一旦所有三个
我正在使用 Ext JS 4.1.1 为网页创建 GUI。我尝试创建一个组件(下面的“GeneSearchComponent”),我可以在更复杂的布局中使用它。但出于某种原因,我无法将“GeneSea
我有这个面板。它按以下顺序显示工具图标:齿轮、关闭、折叠。我想得到的图标是这样的顺序:齿轮、折叠、关闭。我想不通。当我把 collapseFirst: true 放在第一位时,collapse 就在第
我正在使用 ExtJS 4.1.1a,我正在尝试为“tabbedPane”和带有“Accordion”布局的普通面板创建一个新主题。我无法更改每个标题的颜色。也就是说选项卡和选项卡的背景以及 Acco
根据MSDN - Panel.InternalChildren Property : Classes that are derived from Panel should use this prope
我有一个 Ext.Tab,Panel,我在其中动态创建了多个选项卡。 每个选项卡都包含一个 Ext.panel.panel。我需要做的是在选项卡中添加工具提示。我试图做这样的事情: Ext.defin
我有一个带有面板标题和面板主体的 Bootstrap v3 面板。我希望用户能够单击面板标题,它将折叠/展开面板主体。我正在使用 Bootstrap 的 Collapse javascript 来执行
我正在尝试在 ExtJS 中创建一个布局,它在顶部和底部的左右部分都有一个网格,一个基本的父/子、主/详细布局: wrapper_panel panel_top [grid] panel_bott
我正在使用 Extjs 6.0 开发网络 gis和 OpenLayers 3.6.0在 MVVM 架构中。我想把 ol.map到 Ext.panel.Panel .元素主视图如下: Ext.defin
我需要在 Python 中创建一个散布矩阵。我尝试使用 scatter_matrix 来实现此目的,但我只想保留对角线上方的散点图。 我正处于真正的开始阶段(没有走得太远),当列有名称(不是默认数字)
如果您在表单上创建一个面板并将其设置为 Dock=Top,然后放下另一个面板并设置其 Dock=Fill,它可能会填满整个表单,而忽略第一个面板。更改 Tab 键顺序没有任何作用。 最佳答案 停靠布局
我正在设计一个屏幕,其中标题有一个具有某些功能的按钮。为了实现这一点,我使用了 Ext.panel.Panel 现在我想在此屏幕中的标题下方添加列。这是我的代码: var screen = Ext.c
我有一个在 Ext.panel.Panel 上扩展的类。 简化代码: Ext.define("some.namespace.MyOwnPanel", { extends: "Ext.panel
在 Bootstrap 中,如何在单击另一个面板时使面板自动折叠,以便一次只打开一个面板?我不太擅长 JavaScript。 这里是一些示例代码: Information
我有一个主 JPanel,它实现了 Scrollable 并使用了 BorderLayout。它包含一个 NORTH 只读 JEditorPane、一个带有 FlowLayout 的 CENTER J
我正在用 wxPython 开发一个 GUI。我在另一个代表 CD 容器对象的正方形(也有 wxPanel 类)内绘制一个代表 CD 对象的正方形。我想在 CDWindow 的右键菜单中有“删除这张
我在第一个 div 中有两个字段集,然后我使用面板,但我的面板从 div 上方覆盖,请看下面的屏幕截图 1.) 带有文件集和详细信息2.) 添加面板后,Panel-heading to page 覆盖
我有一个 wx.Frame,其中有一个主 wx.Panel,里面有几个小部件。我想要那里的一个按钮导致出现“帮助面板”。这个帮助面板可能是一个 wx.Panel,我希望它覆盖整个主 wx.Panel(
我是一名优秀的程序员,十分优秀!