1. #1
    Sencha User
    Join Date
    May 2012
    Location
    rome
    Posts
    68
    Answers
    3
    Vote Rating
    0
    alexdran is on a distinguished road

      0  

    Default Answered: manage store by controller: how to set proxy and load Data() with parameters

    Answered: manage store by controller: how to set proxy and load Data() with parameters


    Hello all,
    I have a Panel view whose data (loaded from a store) depends on a proxy parameter (GET parameter for the json data retrieved). Store has then autoload = false set

    I'm trying then (on the panel activation) to:
    - get store ID
    - set proxy parameter for the store (url)
    - load data (store.load()) if I'm correct
    - take the data and put on the panel HTML


    however there is no way I can have the store filled with data (unless I'm misunderstanding some commands / point of my code)

    here is the example

    store:

    Code:
    Ext.define('app.store.CDetail', {
        extend: 'Ext.data.Store',
    
    
        config: {
            storeId: 'cdetailstore',
            model: "app.model.Data",
    
    
    
    
            proxy: {
                type: 'ajax',
                url: 'www.myserver.com/info.php?task=infodetail&id=1&type=",
                reader: {
                    type: 'json'
                }
            },
            autoLoad: false
        }
    });
    Model:

    Code:
    Ext.define('app.model.Data', {
        extend: 'Ext.data.Model',
        config: {
            fields: [
                {name: 'data', type: 'string'}
            ]
        }
    
    
    });

    Controller:

    Code:
    Ext.define('app.controller.CDetail', {
        extend: 'Ext.app.Controller',
        
        config: {
            refs: {
                CDetail: 'CDetail'
            },
            control: {
                'CDetail': {
                    activate: 'fillDetail'
                }
            }
        },
        fillDetail: function() {
            var store = Ext.getStore('cdetailstore');
            var detailPanel = this.getConferenceDetail();
            var type = detailPanel.config.type;
            store.load();
    
            debugger;
        }
        
    });
    store array data is always 0
    can someone help me please???

    thank you in advance
    alex

  2. 1.the store should have a rootProperty
    2.when load the store you can send params dynamiclly like this:
    Code:
    store.load({
    params: { ... }, callback: function(records, opertion, success) { ... }, scope: this
    });

  3. #2
    Sencha User
    Join Date
    Apr 2012
    Location
    ShenZhen, China
    Posts
    52
    Answers
    11
    Vote Rating
    2
    liaoyiwu is on a distinguished road

      0  

    Default


    1.the store should have a rootProperty
    2.when load the store you can send params dynamiclly like this:
    Code:
    store.load({
    params: { ... }, callback: function(records, opertion, success) { ... }, scope: this
    });

  4. #3
    Sencha User
    Join Date
    May 2012
    Location
    rome
    Posts
    68
    Answers
    3
    Vote Rating
    0
    alexdran is on a distinguished road

      0  

    Default


    worked!!! many thanks

    I have finally accessed data with

    records[i].get('data')


    best, Alex

Thread Participants: 1

Tags for this Thread