View Full Version : Ext.Flatten Not flatening array correctly

16 Jun 2011, 12:11 PM
Hello All,

Its the first time I'm using the Ext.flatten and I don't know if it behaving properly. I have the flowing array of arrays which I would like to be in 1 single array.

From my understanding the Ext.flatten should return all the elements (C_MGMT.. : VALUE) into 1 array {}.

Thanks in advance for any assistance in this matter.


{"C_MGMT_ID":"","CUST_ID":"1","C_MGMT_TARGET_TYPE":"Server","C_MGMT_TARGET":"858","CHANGE_MGMT_PRIORITY":"P1- High"},{"C_MGMT_USER":"ADMIN","C_MGMT_START_DATE":"2011-06-16 15:47:11","C_MGMT_END_DATE":"2011-06-16 15:47:14","C_MGMT_OUTAGE":"NO","C_MGMT_EXT_REF":"13591","C_MGMT_EST_TIME":"1"},{"C_MGMT_SUBJECT":"Replace 2 disks","C_MGMT_DESCRIPTION":"Replace 2 disks","C_MGMT_REASON":""},{}]

16 Jun 2011, 5:41 PM
You do not have an array of arrays, you have an array of objects.

By the sounds of it you're looking to merge the objects into one object? For that you'd use either Ext.apply() or Ext.applyIf(). Possibly something like this to merge an array of objects in a single object called obj:

var obj = {};

Ext.each(array, function(entry) {
Ext.apply(obj, entry);

17 Jun 2011, 5:04 AM

Thanks, that was the solution using Ext.apply!