Results 1 to 9 of 9

Thread: Unable to override Ext.data.writer.Json configs

    Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1

    Default Unable to override Ext.data.writer.Json configs

    Ext version tested:
    • Ext 5.1.0.107
    Browser versions tested against:
    • Chrome
    Description:
    • Unable to override Ext.data.writer.Json configs
    Steps to reproduce the problem:

    The result that was expected:
    • Configs are overridden correctly and accessible via getters.
    The result that occurs instead:
    • Configs are not applied via override. Getters return original defaults.

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,256

    Default

    There isn't really a bug here. Overrides need to be applied to classes before the instance is first created. In this case, the ext-empty-store is created when the StoreManager loads, which, by default, creates a reader/writer.

    I guess we could fashion it in such a way that it skips the creation of those parts.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3

    Default

    Hi Evan,

    I just don't understand why the override works for the Xml writer but not the Json writer.

    Also the example demonstrates the creation of a writer directly without a store.

    Thanks!

  4. #4

    Default

    Sorry my bad the fiddle link text is different to the actual link in original post. *Sigh*

    https://fiddle.sencha.com/#fiddle/iqj


    Updated original post too.

  5. #5
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,256

    Default

    The defaults of the class are determined on first instance creation. In that fiddle, an empty store is created as part of the "startup" of the framework, which, by default creates a reader/writer for the store. As such, by the time you go to apply your overrides the first instance already exists.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  6. #6

    Default

    Ok thanks Evan, makes sense. It's interesting because I've only noticed this with the dynamic loader. If the overrides are bundled with the rest of the framework using senchacmd then they appear to apply appropriately before the empty store is created.


  7. #7
    Sencha Premium Member
    Join Date
    Jun 2013
    Location
    Marietta, GA
    Posts
    16

    Default

    Is there a suggested alternative then to override the default value for a flag like writeAllFields?

  8. #8
    Sencha Premium User
    Join Date
    Oct 2016
    Posts
    49

    Default

    I'm trying the same, it's possible to override it?

    using 6.2.1

  9. #9
    Sencha Premium Member
    Join Date
    Jun 2013
    Location
    Marietta, GA
    Posts
    16

    Default

    This is what we did to override the default.

    Code:
    Ext.define('Overrides.data.writer.Json', {
        override: 'Ext.data.writer.Json',
    
        constructor: function (config) {
            this.callParent(arguments);
    
            if (!config || !Ext.isDefined(config.writeAllFields)) {
                this.setWriteAllFields(true);
            }
        }
    });
    I don't love this approach, but it works.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •