Results 1 to 7 of 7

Thread: Load nested localstorage data workaround

  1. #1
    Sencha Premium User zmagyar's Avatar
    Join Date
    Mar 2012
    Location
    Budapest
    Posts
    94
    Answers
    1

    Default Answered: Load nested localstorage data workaround

    There is a confirmed bug at http://www.sencha.com/forum/showthre...ssociated-data

    So the associations do not work if localstorage is used. I assume there is some workaround but I couldn't find any.

    I.e. I have two models:

    Code:
    Ext.define('App.model.Contact', {    extend: 'Ext.data.Model',
        config: {
            fields: [
                {
                    name: 'id'
                },
                {
                    name: 'firstname',
                    type: 'string'
                },
                {
                    name: 'lastname',
                    type: 'string'
                },
                {
                    name: 'customer_id'
                }
            ]
        }
    });
    
    Ext.define('App.model.Customer', {
        extend: 'Ext.data.Model',
        alias: 'model.Customer',
        config: {
            fields: [
                {
                    name: 'id'
                },
                {
                    name: 'company',
                    type: 'string'
                },
                {
                    name: 'created',
                    type: 'int'
                }
            ],
            hasMany: {
                model: 'App.model.Contact',
                autoLoad: true,
                name: 'contacts'
            }
        }
    });
    When the customer store is loaded I would like to get all the related contacts to be loaded. This doesn't seem to be working in case of localstorage. I have tried to do this manually listening on the customer store load event but I got problems filtering the data there.

    Any clue would be quite useful as I seem to be stuck with this since a few days now.

  2. Some example with read override:

    http://www.senchafiddle.com/#RqoN5


    n
    ot very elegant what it is there but a sample

  3. #2
    Sencha Premium User bluehipy's Avatar
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    628
    Answers
    67

    Default

    You can hook on proxy read method to do manually the correspondent association load.

  4. #3
    Sencha Premium User zmagyar's Avatar
    Join Date
    Mar 2012
    Location
    Budapest
    Posts
    94
    Answers
    1

    Default

    Can you give me an example please?

  5. #4
    Sencha Premium User bluehipy's Avatar
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    628
    Answers
    67

    Default

    Some example with read override:

    http://www.senchafiddle.com/#RqoN5


    n
    ot very elegant what it is there but a sample

  6. #5
    Sencha Premium User zmagyar's Avatar
    Join Date
    Mar 2012
    Location
    Budapest
    Posts
    94
    Answers
    1

    Default

    Thanks, that's useful. There is a different problem now... Sencha Architect doesn't allow reader definition for localstorage proxies.

  7. #6
    Sencha Premium User bluehipy's Avatar
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    628
    Answers
    67

    Default

    I am sorry but I am not familiar with Sencha Architect but I don 't see how and why would that be prohibited ?

  8. #7
    Sencha Premium User zmagyar's Avatar
    Join Date
    Mar 2012
    Location
    Budapest
    Posts
    94
    Answers
    1

    Default

    Certainly that's not the first bug in their dev app.

Posting Permissions

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