Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8002059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:15:24+00:00 2026-06-04T16:15:24+00:00

I extended an existing Model by adding fields using the prototype. Everything works fine,

  • 0

I extended an existing Model by adding fields using the prototype. Everything works fine, the data can be received from the server side and can be used on client side. But, when I now update my data and send it back to the server side, the “new” fields are not recognized by the writer of the proxy.

To be more specific: I have a model like this:

    Ext.define('Osgaar', {
      extend: 'Ext.data.Model',
      fields: [
        { name: 'first', type: 'string' },
        { name: 'second', type: 'string' },
        { name' 'third', type: 'string' }
      ],

      proxy: {
        type: 'rest',
        url: 'public/svcmethod',
        reader: {
          type: 'json',
          root: 'data'
        },
        writer: {
          type: 'json',
          writeAllFields: false
        }
      }
    });

I am extending the model like that:

    Osgaar.prototype.fields.add({ name: 'fourth', type: 'string' });

I tried to set writeAllFields to false to get all attributes transferred, there are just those from the defined model, not the one added using the prototype (Fiddler confirms that).

Does anybody now a way to solve this without defining a new model?

Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:15:25+00:00Added an answer on June 4, 2026 at 4:15 pm

    I think the best solution here is the following:

    Osgaar.prototype.fields.add(new Ext.data.Field({ name: 'fifth', type: 'string'})); // create Ext.data.Field constructor, not just simple Object
    

    I did a quick look on the Writer implementation, and here is a method that is called by write() when you write data:

    getRecordData: function(record) {
            var isPhantom = record.phantom === true,
                writeAll = this.writeAllFields || isPhantom,
                nameProperty = this.nameProperty,
                fields = record.fields,            // <- look here
                data = {},
                changes,
                name,
                field,
                key;
    
            if (writeAll) {
                fields.each(function(field){
                    if (field.persist) {           // <- checks the persist property!
                        name = field[nameProperty] || field.name;
                        data[name] = record.get(field.name);
                    }
                });
    

    Then I checked the value of persist property of a field that’s added to the prototype after the model is defined and turned out it’s undefined. This is because you are not truly creating an Ext.data.Field instance that would inherit all Field defaults and other useful stuff, you’re simply adding a plain Object to the fields collection. Osgaar.prototype.fields is just a MixedCollection and since you’re working with it directly, there’s no place where Ext.data.Field constructor might be called implicitly.

    If it’s common for your application logic to add Model fields on the fly, consider implementing an addField() method to your custom Models (create another base class in the inheritance chain).

    Hope this helps, good luck!
    I’ve been using ExtJS for quite a while so this was like a quiz to me 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I extended the JAAS javax.security.auth.spi.LoginModule, and installed it into a WAS server. It works;
I have an existing .NET 3.5 based framework that is extended using custom plugins.
I extended the User model in django to include several other variables, such as
I extended the functionality of a line object using a class which takes a
I have extended Ext.data.Operation to implement a custom commitRecords method. The Ext.data.Operation class is
I have one extended Data Table in payeeSearch.xhtml displayed as - 1) After clicking
Can anyone guide me through the right way to add an existing Helper into
I'm confused about something in the SSL renewal process using WHM/cPanel for an existing
I have an existing site build in c# 3.5 using asp.net mvc 1. There
I am using OLEDB to INSERT INTO an existing Excel worksheet. But I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.