【问题标题】:How to insert value in extJS displayfield in dom element如何在 dom 元素的 extJS 显示字段中插入值
【发布时间】:2020-09-14 17:45:48
【问题描述】:

这是我的显示字段配置,它是表单面板的项目..

{
    fieldLabel: "Class"
    itemId: "class"
    name: "class"
    readOnly: true
    value: "my Class"
    xtype: "displayfield"
}

我有一个工作正常的 extJS 显示字段,但在某些情况下,即使值可用,值也不会显示。甚至值是在渲染方法之后进来的。

 afterrender: function(val, eOpts){
        let _this = this,
            view = _this.getView();
            console.log(view.itemId +" "+view.value);
            
           
    } 
    

经过深入调试后,我注意到值本身不在 dom 中。所以我打算在 dom afterrender 方法中插入元素。谁能建议我如何在 displayfield dom 中插入值。

我的 id 是这样的,但这不能正常工作。有些时候风格和标签只会消失。

afterrender: function(val, eOpts){
        let _this = this,
            view = _this.getView();
            console.log(view.itemId +" "+view.value);
             view.el.dom.innerText = view.value;
           
    } 

【问题讨论】:

  • 显示字段为空时结帐收入数据(json?)。
  • 我正在从数据中获得价值。
  • 什么样的数据?您可以为您的表单显示传入的 json 吗?
  • 我正在使用 mongo,所以我提供的 json 数据形成了有问题的字段配置,只有我得到。
  • 错误似乎在不同的地方。试试:Ext.first('#formItemId').getForm().findField('displayFieldName').setValue(12)。这是一种将数据填充到显示字段中的两种可能方法

标签: javascript extjs extjs6


【解决方案1】:

尚不清楚您的字段如何获取数据。 如果我理解正确,您应该像这样使用 displayfield.setValue() 方法:

here is working fiddle

根据您的描述,很难理解 displayfield 不显示某些值的原因。但是您可以通过查看 console.log(IdOfYourDisplayField);

自行检查

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-05
    • 1970-01-01
    • 2014-11-14
    • 1970-01-01
    • 2013-02-19
    • 2021-03-22
    • 1970-01-01
    相关资源
    最近更新 更多