There is a json(#json) like as follow, in student section, first two one is a group, last two one is a group.(group by a set of no. like no.1 and no.2 are one set).
The problem is i need fetch the data from student section and make 2 table (depend on how many set of no., 2 in this example). How to modify the json data structure programmatically that i can fetch the data to do above thing?
The table(#table1) look like :
no. name
1 tom
2 jacky
no. name
1 tom
2 jacky
#json
{
"people": {
"student": [{
"name": "tom"
"no.": "1"
"other": "a"
},{
"name": "tom"
"no.": "1"
"other": "e"
},{
"name": "jack"
"no.": "2"
"other": "d"
},{
"name": "tom"
"no.": "1"
"other": "c"
},{
"name": "tom"
"no.": "1"
"other": "d"
},{
"name": "jack"
"no.": "2"
"other": "g"
}]
}}
here is my jsRender template:
<table>
<thead>
<tr><td>Table 1</td></tr>
<tr><td>no.</td><td>name</td></tr>
</thead>
<tbody>
{{for student}}
<td>{{>no.}}</td>
<td>{{>name}}</td>
{{/for}}
</tbody>
</table>
It will output:
no. name
1 tom
2 jacky
1 tom
2 jacky
How can i modify my template to make the output like #table1
You need something like this:
I don’t know how your template engine works so I used the print function to show what is needed to be added in the template.