显示区域中文本字段的显示值

时间:2017-05-24 10:53:48

标签: extjs textfield setvalue displayfield

我有一个文本字段和一个显示字段。我希望文本字段的用户值显示在显示字段中。我该怎么做?

我的代码如下:

Failed tests:   
  testDestinationExistsAndSameFileWindows(org.apache.flume.client.avro.TestSpoolingFileLineReader): Platform not recognized
  testIncludePattern(org.apache.flume.client.avro.TestReliableSpoolingFileEventReader): Expected 5 files in working dir
  testIgnorePattern(org.apache.flume.client.avro.TestReliableSpoolingFileEventReader): Expected 5 files in working dir
  testIncludeExcludePatternNoConflict(org.apache.flume.client.avro.TestReliableSpoolingFileEventReader): Expected 5 files in working dir
  testIncludeExcludePatternConflict(org.apache.flume.client.avro.TestReliableSpool

ingFileEventReader): Expected 5 files in working dir

Tests run: 410, Failures: 5, Errors: 0, Skipped: 2
.
.
    [INFO] Apache Flume ....................................... SUCCESS [  1.453 s]
    [INFO] Flume NG SDK ....................................... SUCCESS [  5.688 s]
    [INFO] Flume NG Configuration ............................. SUCCESS [  2.438 s]
    [INFO] Flume Auth ......................................... SUCCESS [  10.654 s]
    [INFO] Flume NG Core ...................................... FAILURE  [  8.792 s]

1 个答案:

答案 0 :(得分:4)

最快的实现将是文本字段上的监听器:

listeners: {
    change: function(field, newValue) {
        field.nextSibling().setValue(newValue)
    }
}

或者您在父容器上使用viewModel并绑定该值,这样可以提高可重用性:

xtype:'panel',
viewModel:{
},
items:[{
    xtype: 'textfield',
    fieldLabel: 'Textfield',
    allowBlank: false,
    bind: {
        value: '{value}'
    }
},{
    xtype: 'displayfield',
    fieldLabel: 'Textfield Value',
    bind: {
        value: '{value}'
    }
}]

两种实现的小提琴:https://fiddle.sencha.com/#view/editor&fiddle/206o