Fix List groupby display on linked fields or text

When you group a list on a calculated field (which is stored in the database as a text type) or on a linked field, the groupby row displayed is missing the group-by value or the anchor is screwed up by the link.

These are caused by use of non-raw placeholders. Also, code seems to be much more complicated than it needs to be - it gets the group-by clause used to get the data and it can use this for processing.

This fix simplifies the code (until it has been reviewed, old code has been commented out rather than removed) and makes it work as advertised.