Results 1 to 7 of 7

Thread: Problems with model, restservice and id property

  1. #1
    Sencha Premium User
    Join Date
    May 2013
    Posts
    5

    Default Answered: Problems with model, restservice and id property

    Hi,

    I have a problem with the property id and the restservice, my model is:

    Code:
      Ext.define('PetCalendar.model.pets.PetModel', {
        extend: 'Ext.data.Model',
        idProperty: 'id',
    
        fields: [
            {
                name: 'id', 
                type: 'int',
                identifier: true,
                persist: true
            },
            { name: 'name' },
            {
                name: 'birthDay',
                type: 'date',
                format: 'Y-m-d',
                dateFormat: "c"
            }...
    And i have a form, in the form i want to create a new record, i send data through rest service, but in my request
    the body is this:


    Capture.PNG


    the id property contain an strange value ("PetCalendar.model.pets.PetModel-1", i never set value to this property), and for this reason the rest service reject my request, the rest service wants an integer value, but the value is string.

    Any can helpme with this?

    Thanks.

  2. Ah ok. In that case, you should be able to configure the writer on the proxy like so:

    Code:
    proxy: {
        type: 'rest',
        writer: {
            type: 'json',
            writeRecordId: false
        }
    }
    http://docs.sencha.com/extjs/6.2.1/m...-writeRecordId

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

    Default

    To clarify, you want the client to generate an integer? Or you want it generated by the server and to pass nothing for the id field?
    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.

  4. #3
    Sencha Premium User
    Join Date
    May 2013
    Posts
    5

    Default

    Quote Originally Posted by evant View Post
    To clarify, you want the client to generate an integer? Or you want it generated by the server and to pass nothing for the id field?

    the client generate an string (i think the value is generated by extjs framework).

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

    Default

    Yeah I understand that, what I'm asking is what behaviour you're looking for.

    Do you want the client to generate unique ids, or do you want the server to generate the id (which probably means you don't want to send the id to the server).
    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. #5
    Sencha Premium User
    Join Date
    May 2013
    Posts
    5

    Default

    Oh!, sorry, the server side generate the Id

  7. #6
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,257
    Answers
    759

    Default

    Ah ok. In that case, you should be able to configure the writer on the proxy like so:

    Code:
    proxy: {
        type: 'rest',
        writer: {
            type: 'json',
            writeRecordId: false
        }
    }
    http://docs.sencha.com/extjs/6.2.1/m...-writeRecordId
    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.

  8. #7
    Sencha Premium User
    Join Date
    May 2013
    Posts
    5

    Default

    Quote Originally Posted by evant View Post
    Ah ok. In that case, you should be able to configure the writer on the proxy like so:

    Code:
    proxy: {
        type: 'rest',
        writer: {
            type: 'json',
            writeRecordId: false
        }
    }
    http://docs.sencha.com/extjs/6.2.1/m...-writeRecordId
    Nice, very thanks!

Similar Threads

  1. Child model inherits unwanted id property from base model
    By mcelotti in forum Sencha Touch 2.x: Bugs
    Replies: 1
    Last Post: 30 Jun 2015, 7:46 AM
  2. Replies: 1
    Last Post: 4 Nov 2014, 10:31 PM
  3. Replies: 6
    Last Post: 6 Feb 2012, 7:08 AM
  4. problems on Ext.Window constrain property
    By ruralclimber in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 15 Dec 2008, 9:01 AM
  5. Problems with .html Property of Panel (only available once?
    By mortenscoobo in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 4 Mar 2008, 2:43 AM

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
  •