简体   繁体   English

如何使单元格编辑单元格比实际列宽?

[英]How to make cellediting cells wider than the actual column?

Very simple scenario: I want to have a small grid for a good overview. 非常简单的场景:我希望有一个小的网格以获得良好的概览。 But when clicking in a cell the editor should have a higher width than the actual column. 但是,单击单元格时,编辑器的宽度应比实际列的宽度大。

Example: https://fiddle.sencha.com/#fiddle/reg&view/editor 示例: https//fiddle.sencha.com/#fiddle/reg&view/editor

I tried to specify the width and I tried to add it in the afterrender. 我尝试指定宽度,然后尝试在后渲染中添加宽度。 Width is always exactly as wide as the column. 宽度始终与列完全一样。 Same problem with textareas. textareas的同样问题。

editor: {
    xtype: 'textfield',
    enableKeyEvents: true,
    selectOnFocus: true,
    width: 500,
    listeners: {
        afterrender: function (field) {
            field.setWidth(500);
        }
    }
}

I thought this should be easy but I couldn't find a way to accomplish that. 我以为这应该很容易,但是我找不到实现该目标的方法。 I can specify the height on a textarea but the width isn't considered. 我可以在文本区域上指定高度,但不考虑宽度。

Check below fiddle. 检查下面的小提琴。 https://fiddle.sencha.com/#fiddle/27bv&view/editor Here I have done change for setting width of table node in which cell editor is rendered by Ext.get(Ext.get(Ext.query('div.x-grid-editor')[0]).dom.childNodes[0]).setWidth(300) . https://fiddle.sencha.com/#fiddle/27bv&view/editor在这里,我完成了对表格节点宽度设置的更改,其中Ext.get(Ext.get(Ext.query('div.x-grid-editor')[0]).dom.childNodes[0]).setWidth(300)

This approach is having one limitation - for first time width is not getting set as in beforeedit event we do not get instance of editor.If we get this instance we can apply similar logic for setting editor's width. 这种方法有一个局限性 -因为第一次宽度没有像beforeedit事件那样被设置,所以我们没有得到编辑器的实例。如果得到这个实例,我们可以应用类似的逻辑来设置编辑器的宽度。 please check if it could solve your issue or not.Also let me know for any changes. 请检查它是否可以解决您的问题。如有任何更改,请随时告诉我。 Note: I have impl. 注意:我暗示。 this thing for first column only. 这个东西仅用于第一列。

Okay, I figured out a solution which is pretty close to mine. 好的,我想出了一个非常接近我的解决方案。

afterrender: function (field) {
  field.bodyEl.setWidth(500);
}

This works for textareas and textfields with Ext version 5. I found out that in my fiddle I also used the wrong Ext version. 这适用于Ext版本5的文本区域和文本字段。我发现在我的小提琴中我还使用了错误的Ext版本。 Seems not to work with Ext 4. 似乎不适用于Ext 4。

https://fiddle.sencha.com/#fiddle/27cc&view/editor https://fiddle.sencha.com/#fiddle/27cc&view/editor

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM