1. #1
    Sencha User
    Join Date
    Jan 2012
    Location
    Kraków
    Posts
    8
    Vote Rating
    1
    PavlaQ is on a distinguished road

      0  

    Default Answered: Assocative array problem

    Answered: Assocative array problem


    Hi, I've got a problem with assocative array. I want create dynamically assocative array with dynamic creating / removing elements. My code is:

    Code:
    var tab = new Array();
    
    //create element
    Ext.Array.insert(tab, 0, {
     'db': 'aaa',
     'dbit': 'aaa'
    });
    
    //remove element
     Ext.Array.erase(tab, index, 1);
    Why this code don't working? How I can do this correct?

  2. Hi,

    you can use following code, you have to pass items array instead of object like below:

    Code:
    var tab = new Array();
    
    //create element
    Ext.Array.insert(tab, 0,[['xyz'],['A'],['B']]);
    //remove element
     Ext.Array.erase(tab, 0, 1);
    
    alert(tab);
    check this link :http://docs.sencha.com/ext-js/4-1/#!/api/Ext.Array-method-insert
    see this link also for example :http://jsfiddle.net/RCFwe/3/

  3. #2
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    Answers
    124
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    Hi,

    you can use following code, you have to pass items array instead of object like below:

    Code:
    var tab = new Array();
    
    //create element
    Ext.Array.insert(tab, 0,[['xyz'],['A'],['B']]);
    //remove element
     Ext.Array.erase(tab, 0, 1);
    
    alert(tab);
    check this link :http://docs.sencha.com/ext-js/4-1/#!/api/Ext.Array-method-insert
    see this link also for example :http://jsfiddle.net/RCFwe/3/
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  4. #3
    Sencha User
    Join Date
    Jan 2012
    Location
    Kraków
    Posts
    8
    Vote Rating
    1
    PavlaQ is on a distinguished road

      0  

    Default


    Thank you!
    But I need use own index names for elements. I'm trying this method but again I do it wrong ;/

    Code:
    var tab = new Array();
    
    //create element
    Ext.Array.insert(tab, 0,[['xyz'],['A'],'test' : ['testtesttest']]);
    //remove element
    Ext.Array.erase(tab, 0, 1);
    
    alert(tab);

Thread Participants: 1

Tags for this Thread