PDA

View Full Version : Assocative array problem



PavlaQ
12 Nov 2012, 1:23 AM
Hi, I've got a problem with assocative array. I want create dynamically assocative array with dynamic creating / removing elements. My code is:



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?

sword-it
12 Nov 2012, 2:31 AM
Hi,

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




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
(http://docs.sencha.com/ext-js/4-1/#!/api/Ext.Array-method-insert) see this link also for example :http://jsfiddle.net/RCFwe/3/

PavlaQ
12 Nov 2012, 2:50 AM
Thank you!
But I need use own index names for elements. I'm trying this method but again I do it wrong ;/



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);‚Äč