views:

37

answers:

1

I've just begun using StringTemplate (from stringTemplate.org) and I'd like to know how to achieve grouping in the results.

e.g.

Month , ID
__________________
Jan ,1
Jan ,2
Feb ,3
Feb ,4
Feb ,5
Mar ,6
Mar ,7
Mar ,8
Mar ,9

so that the results when grouped by month look something like:

Jan:
1
2
Feb:
3
4
5
Mar:
6
7
8
9

A: 

Hi. it all depends on how you send in the data. ST won't do any computation for you, which normally includes what belongs in what set.

Terence Parr
the data sent could simply be an array of objects that may contain identical Month properties. Or perhaps a datatable.either way... Is restructuring the source data the only answer?
X-Dev
I think so. ST just displays data; it can't group per se.
Terence Parr
If you want more power, I suggest T4, which can do all this and much more (i.e. Using a LINQ GroupBy on your data within the template itself.)
Kirk Woll