如何获取物品的id值(物品内)?
问题描述:
我需要的ID值,这样做:如何获取物品的id值(物品内)?
Application.Exaple = Ext.extend(Ext.form.FormPanel, {
record_id : 0,
initComponent : function() {
Ext.apply(this, {
items: [
{
name : 'id',
id : 'id',
fieldLabel : 'ID',
readOnly : true,
hidden : true,
listeners : {
'render' : function() {
this.record_id = this.value;
}
}
},
{
name : 'pum',
id : 'pum',
handler : function() {
alert(this.record_id); // not work
}
,但不起作用。我究竟做错了什么?
答
这看起来像是范围错误。
您尝试引用记录,而当前的“this”是按钮。
你可以做的两两件事之一:从外面这样
{
name : 'pum',
id : 'pum',
scope: YOUR OBJECT HERE,
handler : function() {
alert(this.record_id); // not work
}
2)注册按钮的单击事件:
1)传递一个范围,处理程序这样
你叫你的init方法的基本形式超类后...
{
...
this.numBtn = this.items.itemAt(1);
this.numBtn.on('click',function(){YOUR LOGIC HERE},YOUR SCOPE HERE);
}
希望这帮助...