简体   繁体   English

在extjs textfield中如何动态更改afterSubTpl?

[英]In extjs textfield how can I change afterSubTpl dynamically?

I am facing problem in dynamically changing afterSubTpl that I have used in textfield . 我在动态更改在textfield中使用的afterSubTpl问题。 Is there any way that I can change afterSubTpl afterSubTpl我有什么方法可以改变

Here is a working fiddle 这是一个工作小提琴

Create element: 创建元素:

{
  xtype: 'textfield',
  id: 'mytextfield',
  fieldLabel : 'Text',
  afterSubTpl: ['<div id="{id}-title" data-ref="title">afterSubTpl</div>'],
  childEls: ['title']


}

Select listener of combo box: 选择组合框的监听器:

'select': function(cmb, selected) {
  var textField = Ext.getCmp('mytextfield');
  textField.title.setHtml('<div>new afterSubTpl' + selected.data.name + '</div>');
  textField.title.setStyle({color: "red"});   
}

It uses the childEls logic to reference the HTML DOM Element which was created based on the afterSubTpl config. 它使用childEls逻辑来引用基于afterSubTpl配置创建的HTML DOM元素。 Within the 'select' listener of the combo box the element which was added within the childEls is used to update the HTML content. 在组合框的“select”侦听器中,在childEls中添加的元素用于更新HTML内容。 This Ext.dom.Element can be manipulated according to Sencha Doc 可以根据Sencha Doc操作此Ext.dom.Element

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

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