Results 1 to 8 of 8

Thread: Manipulation of arrays

  1. #1
    Sencha User
    Join Date
    Apr 2013
    Posts
    44
    Vote Rating
    0
      0  

    Default 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
    Answers
    4
    Vote Rating
    3
      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
    44
    Vote Rating
    0
      0  

    Default 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
    Answers
    4
    Vote Rating
    3
      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
    44
    Vote Rating
    0
      0  

    Default 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
    44
    Vote Rating
    0
      0  

    Default 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
    18,425
    Answers
    650
    Vote Rating
    858
      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
    44
    Vote Rating
    0
      0  

    Default 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.

Tags for this Thread

Posting Permissions

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