[英]Render custom Radio button in ExtJS 3
I want to customize the radio button where I need to display text box, or Date field besides radio button instead of text. 我想自定义需要显示文本框的单选按钮,或者自定义单选按钮以外的日期字段而不是文本。
There is a similar question Add custom item to radio button in extjs , but the answer is for ExtJs 4. Can someone please help me with similar implementation for ExtJs 3? 还有一个类似的问题, 将自定义项目添加到extjs中的单选按钮 ,但答案是ExtJs4。有人可以帮我实现类似ExtJs 3的实现吗?
I tried using contentEl
, but the div gets appended below the radio input tag, so is not visible. 我尝试使用contentEl
,但是div附加在单选输入标签下方,因此不可见。 After looking at Ext code I tried overriding private getContentTarget
function and it seems working but doesn't feel the right approach 看完Ext代码后,我尝试覆盖私有的getContentTarget
函数,它似乎可以正常工作,但感觉不正确
Here is a workaround based on the ExtJs 4 answer. 这是基于ExtJs 4答案的解决方法。 Instead of boxLabelEl
, you can use getEl().down('label.x-form-cb-label')
like so: 代替boxLabelEl
,可以这样使用getEl().down('label.x-form-cb-label')
:
listeners: {
render: function( radio ) {
var boxLabelEl = radio.getEl().down('label.x-form-cb-label');
boxLabelEl.update("");
radio.field = Ext.create('Ext.form.field.Number', {
renderTo: boxLabelEl,
width: 40,
disabled: !radio.getValue()
});
boxLabelEl.setStyle('display','inline-block');
},
change: function( radio ) {
radio.field.setDisabled(!radio.getValue());
}
}
This should work for ExtJs 3. 这应该适用于ExtJs 3。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.