1. #1
    Sencha User
    Join Date
    Apr 2013
    Posts
    43
    Vote Rating
    0
    jose_carlos is on a distinguished road

      0  

    Default Unanswered: Manipulation of arrays

    Unanswered: Manipulation of arrays


    Good day. I'm needing help with array manipulation. Does anyone have some code snippet that demonstrates how armezenar values ​​in an array and then retrieve them?

  2. #2
    Sencha User
    Join Date
    Jun 2012
    Location
    India
    Posts
    50
    Vote Rating
    3
    Answers
    4
    girish.arjunagi is on a distinguished road

      0  

    Default


    Use the push function to store the data and pop for retrieving.
    Code:
    var array = [];
    //to store
    array.push('abc');
    array.push('def');
    array.push('ghi');
    //to retrieve
    array.pop();

  3. #3
    Sencha User
    Join Date
    Apr 2013
    Posts
    43
    Vote Rating
    0
    jose_carlos is on a distinguished road

      0  

    Default Resposta Array

    Resposta Array


    Okay, but in the case of array.pop () there is a need to put some parameter? I need to put it into some looping.

  4. #4
    Sencha User
    Join Date
    Jun 2012
    Location
    India
    Posts
    50
    Vote Rating
    3
    Answers
    4
    girish.arjunagi is on a distinguished road

      0  

    Default


    You don't need to pass any parameter for pop. pop will always returns you last element.
    Yes you can loop through array if you want to read all the elements.

    Code:
    var i, length = array.length;
    for( i = 0; i < length; i++ ){
        array.pop()
    }

  5. #5
    Sencha User
    Join Date
    Apr 2013
    Posts
    43
    Vote Rating
    0
    jose_carlos is on a distinguished road

      0  

    Default Resposta

    Resposta


    From what I could see the problem is the push method. Looks like he is not getting inserted. Below is the code snippet.


    selectMarcador.push ([markerId], [record.get ('marker')]);


    It is a two-dimensional array that I'm trying to do. Can you tell me if it is correct?

  6. #6
    Sencha User
    Join Date
    Apr 2013
    Posts
    43
    Vote Rating
    0
    jose_carlos is on a distinguished road

      0  

    Default Complemento

    Complemento


    Just to supplement I'm trying to put a string in the same array and a boolean. Thank you!

  7. #7
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,163
    Vote Rating
    674
    Answers
    474
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Everything you need to know about Arrays:

    https://developer.mozilla.org/en-US/..._Objects/Array

    Ext provides some helper methods too:

    http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.Array
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  8. #8
    Sencha User
    Join Date
    Apr 2013
    Posts
    43
    Vote Rating
    0
    jose_carlos is on a distinguished road

      0  

    Default Resolvido

    Resolvido


    I thank you all for the help. It really has worked. I missed using the prefix "me" that I had not inserted it in my code was no need to access the array.

Thread Participants: 2

Tags for this Thread