-1

We are dealing with special Date objects on server side. So json returns a object. For this we wanted to override the field definition for Ext.data.field.Date

Ext.define('Ext.overrides.data.field.Date', {
    override: 'Ext.data.field.Date',
    convert: function(v) {
        // Do something with v and return it
        console.log('Process value');
        return v;
    }
});

The convert method is never triggered. Configuring the field with a convert method inside of a Model works and the method is called.

We ended up with the following "hack" but are not sure why the "normal override" is not working. Maybe someone can shed some light on that issue.

Ext.define('Ext.overrides.data.field.Date', {
    override: 'Ext.data.field.Date',
    constructor: function(config) {
        var me = this;
        this.convert = config.convert || function(v) {
            // Do something with v and return it
            console.log('Process value');
            return v;
        };
        this.callParent(arguments);
    }
});
MarthyM
  • 1,839
  • 2
  • 21
  • 23
Robert
  • 176
  • 1
  • 19
  • Is your override required in your code? – MarthyM Jun 25 '17 at 17:46
  • No, i am not requiring it but it is loaded. And in the sencha docs you find the following: "This folder contains overrides which will automatically be required by package users." Was adding a console.log to the file and can see that the file gets loaded – Robert Jun 25 '17 at 19:08
  • Rob: did you check code after doing sencha app build/sencha app refresh ? Bcoz these types of changes require above thing to be done. – Tejas Jun 26 '17 at 06:24
  • Yes but had no effect. – Robert Jun 26 '17 at 06:42
  • Could you provide a minimal working [fiddle](https://fiddle.sencha.com/) reproducing your problem? – MarthyM Jun 26 '17 at 20:27
  • 2
    I can provide a [minimal working fiddle NOT reproducing the problem](https://fiddle.sencha.com/#view/editor&fiddle/226r). Therefore voting to close the question as insoluble. – Alexander Jun 26 '17 at 21:16
  • Was testing your fiddle and yes its working. But only when i put my code into the launch method. When having the override in a bundle class inside of the override folder its not. The constructor gets executed but the convert method never gets triggered. How can i get to the bottom of that issue? Was checking but there is no other override for the Date field class. – Robert Jun 27 '17 at 08:04
  • I am very sorry, was checking all my code again and saw that i had a second override in a another package. So it was kind of a race condition with the overrides. Thanks – Robert Jun 27 '17 at 08:11

1 Answers1

0

@Alexander: Going through my code found a second override of the class. So everything is working fine just make sure you only have one override at a time or make sure they are loaded in correct order.

Robert
  • 176
  • 1
  • 19