Results 1 to 4 of 4

Thread: Unable to retrieve record after loading data to store

  1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    3
    Vote Rating
    1
      0  

    Default Unable to retrieve record after loading data to store

    Hi,

    I am developing an app to display directory structure of a server on a mobile platform.

    I have to make two REST proxy calls in a single event 'show' of the list view.

    The 1st call is to get the ID of the base folder. Using this ID, I make a call to retrieve its
    sub folders.

    The 1st call I make during the show event of the list view goes like this:

    Code:
     
       var resolveStore = Ext.getStore("idResolveStore");
        resolveStore.setProxy({
            type: 'rest',
            url: '/Document_Management_App/application?path=%2FProjects',            
            reader: {
                type: 'json'           
        }});
    
    
        resolveStore.data.clear();
        resolveStore.load();
    
    
        var rec =  resolveStore.findRecord("object_name", "Projects");
    The findRecord call always returns null. But I am able to see the record in the server response tab in the browser.

    Using this record i need to make another REST call.

    Am I doing something wrong here? Why am I unable to retrieve the record from the store ?
    AFAIK a model instance need not be set explicitly to a store when you do a load().

    Btw the model which is set to the store is given below:

    Code:
    Ext.define('MyApp.model.ResolveModel', {
        extend: 'Ext.data.Model',
        config: {
            fields: [
                {
                    name: 'r_lock_owner',
                    type: 'string'
                },
                {
                    name: 'object_name',
                    type: 'string'
                },
                {
                    name: 'r_creator_name',
                    type: 'string'
                },
                {
                    name: 'r_creation_date',
                    type: 'string'
                },
                {
                    name: 'r_modifier',
                    type: 'string'
                },
                {
                    name: 'r_modify_date',
                    type: 'string'
                },            
                {
                    name: 'owner_name',
                    type: 'string'
                }
            ]
        }
    });
    Any help would be greatly appreciated.
    Thanks !

  2. #2
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,149
    Vote Rating
    100
      1  

    Default

    The model may not be filled with the data yet. The record is created once the store finishes its load() and fires its load event. Remember that the store's load is done asynchronously. Try retrieving the record after the store fires its load event and you should see your data there.

  3. #3
    Sencha User
    Join Date
    Jun 2012
    Posts
    3
    Vote Rating
    1
      1  

    Default

    Quote Originally Posted by jerome76 View Post
    The model may not be filled with the data yet. The record is created once the store finishes its load() and fires its load event. Remember that the store's load is done asynchronously. Try retrieving the record after the store fires its load event and you should see your data there.
    Thanks jerome76. Using the store's load() event I was able to synchronize my tasks.

  4. #4
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,149
    Vote Rating
    100
      0  

    Default

    Great

Posting Permissions

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