【发布时间】:2012-04-11 03:36:53
【问题描述】:
我使用的是 extjs 3.4 版,但在这一行出现一个错误:
var query = new RegExp(Ext.String.format('field1', e.query.replace(/\?/g, '[A-Za-z0-9]')));
like--Uncaught TypeError: Cannot call method 'format' of undefined
我添加了这样的监听器,如果有任何错误请告诉我。
this.findById('field1').addListener({
beforequery: function (e) {
if (e.query && e.query.indexOf('?') != -1) {
e.cancel = true;
var query = new RegExp(Ext.String.format('field1', e.query.replace(/\?/g, '[A-Za-z0-9]')));
this.expand();
this.store.clearFilter(true);
this.store.filter(this.displayField, query);
}
}
});
【问题讨论】:
-
嗯...消息说,“Exp”或“Exp.String”未定义,因此无法调用“format”。你能找出什么是未定义的吗?你的页面中是否包含了 extjs?
-
嗨 @Tobi 我的 js 文件是 Metadata.js,我没有明确包含 Ext。我在 Ext.extend 方法()中使用上面的代码;你能告诉我如何明确地包含 Ext。
-
类似这样的东西:
-
嗨 @Tobi 感谢您的回复,通过删除 ext 并仅使用 String.format,它可以正常工作。
-
你是对的。这也将起作用:-)