【问题标题】:Problems with extjs treepanel rendererextjs 树面板渲染器的问题
【发布时间】:2026-02-08 22:10:02
【问题描述】:

我想稍微修改默认的树面板渲染器。所以在第一步中,我尝试只调用默认的树面板渲染器。不幸的是,这不起作用。

这是我的代码:

Ext.define('FMSGui.view.FMSFeatureTypeTreePanelColumn',
{
  extend:   'Ext.tree.Column',
  dataIndex: 'name',
  flex:1,
  renderer: function(v1)
  {
      return this.callParent(v1);
  }
}
);

TreePanel 的代码如下所示:

Ext.define('FMSGui.view.FMSFeatureTypeTreePanel', {
    extend: 'Ext.tree.Panel',
    title: 'Feature Types',
    width: 200,
    height: 150,
    store: null,
    displayColumn:null,
    constructor: function(config)
    {
        this.displayColumn=Ext.create("FMSGui.view.FMSFeatureTypeTreePanelColumn");
        this.columns=[this.displayColumn];
        this.store=Ext.create("FMSGui.store.FMSFeatureTypeTreeStore");
        this.store.load();
        this.superclass.constructor.call(this,config);
    },
    rootVisible: true,
    lines: true, 
    useArrows: true 
    });

我总是收到错误消息:

XTemplate 评估异常:this.callParent 不是函数

顺便说一句,如果我删除渲染器部分。

知道这里出了什么问题吗? 感谢您的意见。

【问题讨论】:

  • 没有人知道吗?可惜还是没能解决。

标签: extjs extjs5


【解决方案1】:

这是一个范围问题。在renderer 的闭包中this 不是对FMSGui.view.FMSFeatureTypeTreePanelColumn 的引用(它实际上是对一个窗口的引用),因此没有callParent 属性。

尝试阅读这篇文章:Closuresthis keyword

如果你用return this.callParent(v1); 描述你想要实现的确切目标,我会尝试用一些代码/小提琴来帮助你。

【讨论】:

  • 非常感谢,我想在渲染器中进行国际化,因此,更改 this.callParent(v1);到 this.callParent(translate_map[v1]);抱歉,不小心点击了编辑而不是添加评论,有人可以删除我上面写的部分吗?我不能像看起来那样自己做。