0
votes

I am using extjs version 3.4 and I am getting one error in this line:

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

I added listener like this please let me know if there is any wrong in this.

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);
        }
    }
});
1
Hmm... the message says, that "Exp" or "Exp.String" is undefined, so "format" could not be called. Can you find out, what is undefined? Do you have included extjs in your page?Tobi
Hi @Tobi my js file is Metadata.js and i dint included Ext explicitly. I am using the above code inside Ext.extend method(); Can you please tell how to include Ext explicitly.user27
Something like this: <script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>Tobi
Hi @Tobi thanks for the reply its working fine by removing ext and using only String.format.user27
You are right. This will also work :-)Tobi

1 Answers

0
votes

Just in case you were wondering why it is working with String instead of Ext.String it is because Ext is adding the method to the JavaScript String object.

http://docs.sencha.com/ext-js/3-4/#!/api/String

These functions are available as static methods on the JavaScript String object.

So all of the other function for String that Ext defines (toggle, trim, etc.) will also be on String object and not Ext.String.

Hope that helps for why it wasn't working and for the future.