I am trying to create a table, with some grouping headers. All is well when i have 1 group, but how do i create dynamic groups?
This is what i have so far (for 1 group):
var groupby = '';
arrdata.each(function(element){
if (groupby != element.groupby) {
groupby = element.groupby;
tbody.push(groupby)
}
tbody.push(element)
})
How do i make it create dynamic groups?
You could group them into an
Object
first:Then for .. in through the object:
More generic solution. You can use it directly. Deep copy of objects used. Please note that this solution is of polynomial time
test case:
try with this structure: