I have a list of appointments structured like so (taken from JSON format):
var oData = {
"data": {
"d": {
"results": [
{
"Room": "403",
"Title": "MaLyssa Scott Meeting",
"Category": "Meeting",
"EventDate": "2016-10-31T19:30:00Z",
"EndDate": "2016-10-31T21:00:00Z"
},
{
"Room": "403",
"Title": "OF Upgrade Meeting",
"Category": "Meeting",
"EventDate": "2016-10-13T17:00:00Z",
"EndDate": "2016-10-13T18:00:00Z"
},
{
"Room": "428",
"Title": "IPAC DTID CRM",
"Category": "Meeting",
"EventDate": "2016-10-12T17:30:00Z",
"EndDate": "2016-10-12T18:30:00Z"
},
{
"Room": "434",
"Title": "BPR-12-001 Updates",
"Category": "Meeting",
"EventDate": "2016-10-10T15:00:00Z",
"EndDate": "2016-10-10T15:30:00Z"
},
{
"Room": "436",
"Title": "OF Update Meeting",
"Category": "Work hours",
"EventDate": "2016-10-12T17:00:00Z",
"EndDate": "2016-10-12T18:00:00Z"
},
{
"Room": "454",
"Title": "Real Property Meeting",
"Category": "Meeting",
"EventDate": "2016-10-12T20:00:00Z",
"EndDate": "2016-10-12T21:00:00Z"
}
]
}
}
}
I need to group the results array by Room Number, so for example, Room 403 has 2 children that are siblings of one another rather than 2 separate objects.
I figure I can do this with an 'if' statement and then push the objects into an array for each Room, whats a best practice to perform something like this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…