Results 1 to 3 of 3

Thread: Reading and writing nested data from model

  1. #1
    Sencha User silveralecs's Avatar
    Join Date
    Apr 2012
    Posts
    67
    Answers
    2

    Default Answered: Reading and writing nested data from model

    I'm trying to read and write data to my server using JSON.

    Here's how my model looks like:

    Code:
    Ext.define('App.model.report.Report', {
        extend: 'Ext.data.Model',
        fields: [
            {            
                name: 'name',
                type: 'string'
            },
            {            
                name: 'interval.start',
                type: 'int'
            },
            {
                name: 'interval.end',
                type: 'int',
            }
        ]
    });
    I've noticed that when I make a write, the data in my backend goes like this:

    Code:
    {
         name: 'Test',
         'interval.start': 1,
         'interval.end': 5
    }
    And I would like to look like this:

    Code:
    {
         name: 'Test',
         interval: {
              start: 1,
              end: 5
         }
    }
    I know that there is a mapping property which allows you to change from where to read the value, but how about when you write? Is there anything similar?

    How can I solve this?

    Thank you


  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258
    Answers
    759
    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
    Sencha User silveralecs's Avatar
    Join Date
    Apr 2012
    Posts
    67
    Answers
    2

    Default

    Thank you @evant! Exactly what I was looking for.

Similar Threads

  1. Reading and writing nested JSON values
    By DexterJS in forum Ext: Q&A
    Replies: 2
    Last Post: 2 Jan 2014, 5:04 PM
  2. Reading nested data from JSON into a store
    By direct2kali in forum Ext: Q&A
    Replies: 1
    Last Post: 23 Aug 2012, 6:15 PM
  3. Reading and writing directly to data store.
    By Johnbran in forum Sencha Touch 1.x: Discussion
    Replies: 1
    Last Post: 8 Jul 2011, 9:36 AM
  4. Reading/Writing multiple stores data alltogether with json
    By hazimdikenli in forum Ext 3.x: Help & Discussion
    Replies: 4
    Last Post: 27 Oct 2010, 5:54 AM
  5. question on Reading & Writing from JS
    By Mohammed in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 5 Apr 2007, 6:12 PM

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
  •