For my json object, I need to incorporate an attribute called idField. This idField should be structured as an array if it contains multiple elements, or as an object if it has only one element. I want to generate this idField from the data stored in an extjs store. Essentially, if the store holds just one element, I need to insert an 'object' for idField in the json object, but if there are multiple elements, then I need to insert an 'array'. Can you guide me on how to achieve this?
UPDATE:
The data in my store consists of 2 columns: 'name' and 'type'. If the store has only one row, I want the object structure to be like this:
{
...
idField : {
name : ...
type : ...
}
}
If there are 2 rows in the store, then the object structure should appear as follows :
{
...
idField : [
{
name : ...
type : ...
},
{
name : ...
type : ...
}
]
}
It is important to note that the idField attribute needs to be inserted within the object.
UPDATE 2:
When I executed
console.log(Ext.getStore("My_store_name").data)
, I received this object in the console.