मैंने जांच की कि कैसे ExtJs डोम में फॉर्म के फ़ील्ड प्रस्तुत करता है। क्षेत्र बदलने के बाद फ़ील्ड लेबल बदलने के लिए मुझे उचित डोम तत्व मिलता है और इसके आंतरिक HTML को बदलता है;Extjs फ़ील्ड के बाद फ़ील्ड लेबल बदल दिया जाता है। कोई बेहतर समाधान?
/**
* Modifies field's label afrer field is rendered.
*
* @param {object} field
* Some object that directly or indirecty extends Ext.form.Field
* @param {String} label
* New value for field's label.
*/
function setLabel(field,label){
var el = field.el.dom.parentNode.parentNode;
if(el.children[0].tagName.toLowerCase() === 'label') {
el.children[0].innerHTML =label;
}else if(el.parentNode.children[0].tagName.toLowerCase() === 'label'){
el.parentNode.children[0].innerHTML =label;
}
return setLabel; //just for fun
}
//EXAMPLE:
var win = new Ext.Window({
height : 200,
width : 300,
layout : 'form',
labelAlign : 'right',
items : [{
xtype : 'textfield',
fieldLabel : 'name',
ref : 'f',
html : 'asdf'
},{
xtype : 'datefield',
fieldLabel : 'date',
ref : 'd'
},{
xtype : 'combo',
fieldLabel : 'sex',
ref : 'c',
store : [[1,"male"],[2,"female"]]
},{
xtype : 'radio',
fieldLabel : 'radio',
ref : 'r'
},{
xtype : 'checkbox',
fieldLabel : "checkbox",
ref : 'ch'
}]
}).show()
setTimeout(function(){
setLabel(win.f,'Last Name')(win.d,'Birth Date')(win.c,'Your Sex')(win.r,'jus radio')(win.ch,'just checkbox');
},3000);
हाँ यह काम करता है :)। बहुत बहुत धन्यवाद, यह सही जवाब है जिसे मैं ढूंढ रहा था। – Zango
अब यह 'लेबल एएल' है, न कि' लेबल' ... –