Results 1 to 6 of 6

Thread: Loading grid data from Controller

  1. #1
    Sencha Premium Member
    Join Date
    Jan 2011
    Posts
    12
    Vote Rating
    0
      0  

    Default Loading grid data from Controller

    Hello,

    I'm new with ExtJs4 and after trying a simple grid example I'm not sure about something.
    In my example, I've got a model, a store and a controller that must refresh a simple grid.

    In the controller I can get my store very easily with the auto generate function based on the store name.

    So my question is, why when I get my store with the auto generated function and then make a "load()" on it, the data in my grid aren't loaded ? The only way to load the data in my grid looks like to get the grid store (the same one) and call a "load()" on it : "grid.store.load()"

    Here is my example:

    Code:
    Ext.define('Test.controller.User', {
        extend: 'Ext.app.Controller',    
        models: [
        'Test.model.User'
        ],
        stores: [
        'Test.store.Users'
        ],
        
        init: function() {
            this.control({
                '.userView': {
                    afterrender: this.reloadGrid
                }
            });
        },  
      
        reloadGrid: function(userView) {     
            //This is not loading data in the grid....
            var store = this.getTestUsersStore();
            store.load();
            //This is working...
            userView.store.load();
        }
        
    });
    Thx in advance

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,409
    Answers
    716
    Vote Rating
    504
      0  

    Default

    We will need more information as your snippet is not enough to provide any real detail:

    -Do you have the store assigned to the grid?
    -Do you get a results when you call store.load()
    -What does you return JSON l look like? Is it formatted properly?
    -Are you using a debugger to review your header and response (Firebug / Developer Tools)
    -Do you get any console errors?

    Regards,
    Scott.

  3. #3
    Sencha Premium Member
    Join Date
    Jan 2011
    Posts
    12
    Vote Rating
    0
      0  

    Default

    -Do you have the store assigned to the grid?
    Yes

    -Do you get a results when you call store.load()
    Yes

    -What does you return JSON l look like? Is it formatted properly?
    It looks like exactly the same as the json I get when using grid.store.load(). The only difference is that the grid only refresh data when using grid.store.load().

    -Are you using a debugger to review your header and response (Firebug / Developer Tools)
    Yes

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,409
    Answers
    716
    Vote Rating
    504
      0  

    Default

    Can you provide the JSON or a small working example that displays your problem? I am unable to help with the limited information as there are numerous causes for data not displaying in a grid.

    Scott.

  5. #5
    Sencha User
    Join Date
    Mar 2011
    Location
    Hyderabad
    Posts
    106
    Answers
    10
    Vote Rating
    13
      0  

    Default

    //This is not loading data in the grid.... var store = this.getTestUsersStore(); store.load();

    In the above code you are creating another instance of store.

    store.load()
    This will load data in current instance of store. If you want to load data in the grid panel,
    you need to access the same instance of store which is used in the grid panel.so that
    the data will loaded to that particular store.



    Thanks
    Zinnia

  6. #6
    Sencha Premium Member
    Join Date
    Jan 2011
    Posts
    12
    Vote Rating
    0
      0  

    Default

    This is what I expected Zinnia, ty for confirmation

Posting Permissions

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