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 8967365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:13:36+00:00 2026-06-15T17:13:36+00:00

I have a simple Sencha Touch 2.1 model class: Ext.define(‘App.model.User’, { extend: ‘Ext.data.Model’, config:

  • 0

I have a simple Sencha Touch 2.1 model class:

Ext.define('App.model.User', {
    extend: 'Ext.data.Model',
    config: {
        fields: [
            { name: 'id', type: 'number', defaultValue: 0 },
            { name: 'first', type: 'string' },
            { name: 'last', type: 'string' },
            { name: 'email', type: 'string' },
            { name: 'lastUpdated', type: 'auto' }
        ]
    },
    fullName: function () {
        var d = this.data,
            names = [d.first, d.last];
        return names.join(" ");
    }
});

A collection of these models is in a store that I’ve configured to use sencha’s Rest Proxy. When I add a new model to the store, and call the Sync method on the store, the new model is posted to a ASP.NET WebAPI Users controller and the following action is hit:

    // POST api/Default1
    public HttpResponseMessage PostUser(User user)
    {
        // this is a new user -- get rid of the ID
        user.Id = 0;
        if (ModelState.IsValid)
        {
            db.Users.Add(user);
            db.SaveChanges();

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, user);
            response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = user.Id }));
            return response;
        }
        else
        {
            return Request.CreateResponse(HttpStatusCode.BadRequest);
        }
    }

The problem is that the a string is being sent as the ID for the model, so it’s not passing the ModelState.IsValid check on the controller. This is what’s actually getting sent up:

{"id":"ext-record-5","first":"c","last":"d","email":"e","lastUpdated":null}

Any idea why the id field is being set to a string? Also, any idea how I can tell the post action in the Users controller not to validate the id field (as it should be handling creating a new item, it makes sense for the server to create the ID for the new item, not the client).

  • 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-15T17:13:37+00:00Added an answer on June 15, 2026 at 5:13 pm

    This link helped me figure it out. The updated model should be:

    Ext.define('App.model.User', {
        extend: 'Ext.data.Model',
        config: {
            fields: [
                { name: 'id', type: 'auto', persist: false },
                { name: 'first', type: 'string' },
                { name: 'last', type: 'string' },
                { name: 'email', type: 'string' },
                { name: 'lastUpdated', type: 'auto' }
            ],
        },
        fullName: function () {
            var d = this.data,
                names = [d.first, d.last];
            return names.join(" ");
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Store declared in my sencha touch application Ext.define('Sample.store.ImageStore', { extend:
i have a simple sencha touch app in mvc style with one view in
I have a really simple Sencha Touch 2.0.1 app made with Sencha Architect 2.0.0:
I want to create some simple navigation in sencha touch 2. I have questions
I have simple class with width and height member fields which define number of
I have a toolbar in Sencha Touch 1.1. It's pretty simple: Techlink.views.requestsListToolbar = new
I have an Android app using PhoneGap 1.6 and Sencha Touch 1.1.1. One view
I have a simple Ext JS 4 form inside a window (MVC style app).
I have a simple object (a button in Sencha Touch actually). It's in an
I have learned from the sencha doc how to create a simple MVC application,

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.