1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    62
    Answers
    3
    Vote Rating
    0
    kidqn is on a distinguished road

      0  

    Default Answered: Cannot use getAt() method in initialize function

    Answered: Cannot use getAt() method in initialize function


    I want to show a question with answers in a panel.
    I have a store which stored list of questions as below:
    PHP Code:
    1. Can you help me?
                 
    A.Yes
                 B
    .No
             2. Can you help me
    ?
                 
    A.No
                 B
    .Yes
             3. Can you help me
    ?
                 
    A.Yes
                 B
    .Yes 
    I test in Store.js, create a load: function, it's OK.
    Code:
    load:function(store,record)
    {
                var rec      = store.getAt(1);
                console.log(store)/// CORRECT, array[311]
                console.log(rec); ///it's work, an element in array }
    But in mypanel.js,
    Code:
    initialize:function()
    {          
                var store = Ext.getStore("Listquestion");  
                var rec = store.getAt(0);
                console.log(store)/// CORRECT, array[311]
                console.log(rec); ///// text output: undefined
                console.log(store.getCount()); ///text output: 0
                this.callParent(arguments); 
        },
    Can you help me solve this problem? I think the key is load:function

  2. Thank you! Sorry I found the error is load event of store.
    store.on("load", function(s,rs) {//It's OK}

  3. #2
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    3,964
    Answers
    332
    Vote Rating
    133
    fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all

      0  

    Default


    What does the code for your store look like?

  4. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    62
    Answers
    3
    Vote Rating
    0
    kidqn is on a distinguished road

      0  

    Default


    Thank you! Sorry I found the error is load event of store.
    store.on("load", function(s,rs) {//It's OK}

Thread Participants: 1