如何获取项目的id值(在项目内)?

时间:2011-11-17 09:00:32

标签: extjs3

我需要获取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
                }

但不起作用。我做错了什么?

1 个答案:

答案 0 :(得分:2)

这看起来像是范围错误。

当你的当前'这个'是按钮时,你试图引用记录。

您可以执行以下两项操作之一:

1)将范围传递给处理程序,如下所示:

{
  name    : 'pum',
  id      : 'pum',
  scope: YOUR OBJECT HERE,
  handler : function() {
     alert(this.record_id); // not work
}

2)从外面注册按钮的点击事件,如下所示:

在init方法上调用基本表单超类后...

{
...
this.numBtn = this.items.itemAt(1);
this.numBtn.on('click',function(){YOUR LOGIC HERE},YOUR SCOPE HERE);
}

希望这会有所帮助......

相关问题