views:

1359

answers:

5

When I group items in a SPGridView using the GroupField property the grouping works great but the total row count does not show up like in a standard SharePoint list. Usually SharePoint will display the count next to the group in parenthesis (i.e. Group 1 (5)). Is there a way to enable this functionality.

A: 

have you tried setting the DisplayGroupFieldName property to True?

SPGridView class documentation

Jason
Nope, that didn't do it. If DisplayGroupFieldName is true the grouping looks like "Group Field Name: Group 1". If DisplayGroupFieldName is false the grouping looks like "Group 1".
joegtp
A: 

I had a quick look at the code and even overriding the SPGridview does not seem to have an easy "hook" to override for this.

You may be able to create Javascript to do this, but it would be far from entertaining.

Nat
A: 

Javascript works! Nat advice helped me!

See jquery example below:

$(".ms-gb td:contains('" + groupName + "')")
    .append("<div class='stat'>text</div>")
A: 

I'm new to Jquery. Do you mind sharing the entire JQuery script please?

A: 

If you don't want to use javascript, you could iterate through the table and count the rows in each group.

The downside is that you would probably need to count all of the rows and then go back and update the group name in each row.

For example:

ID  Value   Group
1   One     GroupA
2   Two     GroupA
3   Three   GroupB
4   Four    GroupB
5   Five    GroupB

2 in GroupA
3 in GroupB

ID  Value   Group
1   One     GroupA (2)
2   Two     GroupA (2)
3   Three   GroupB (3)
4   Four    GroupB (3)
5   Five    GroupB (3)
Kit Menke