Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Scenario: DVWP that looks at 3 columns in a library

CreatedBy Name Status

I want to group first on "CreatedBy", then on "Status". But I want the Status groupings to display horizontally, not beneath the first grouping as is the default behavior for a DVWP. I also want to show the count for each status grouping. I've played around with the XSL, many variations but cannot get this to work. Here's what it looks like: a) default DVWP behavior, and b) how I'd like it to look. Any help would be greatly appreciated!

A) Default DVWP behavior (2 groupings, first user expanded: count($nodeset) for status included

-Username1 
   -Status: Not Started (2)
                        test1.docx
                        test2.docx
   -Status: Completed (1)
                        test3.docx
+Username2 
+Username3 
+Username4 

B) How I want it to look (first user expanded: count($nodeset) for status included

             Status:Not Started     Status: Completed
-Username1          2                      1   
             test1.docx             test3.docx
             test2.docx
+Username2         0                       1
+Username3         3                       0
+Username4         2                       2
share|improve this question
    
Madstowe if i understood you want to first expan username and then Status am i right? –  naijacoder Oct 4 '11 at 3:35
    
Naijacoder, well, yes. First is Username, then status. Default behavior is A). In my case, I want the documents that belong to the second grouping to be displayed in their own column beneath the group headers (i.e. status: not started, or status: completed) in horizontal fashion (see a vs. b). Collapsed state is as you see with Username2 - 4...with the count(status) showing in same row for each status. Expand it, and you see the documents that belong to each status grouping. Not sure how else to explain it :) Thanks for replying –  Madstowe Oct 4 '11 at 20:42
add comment

1 Answer 1

To do this, you need think about how XSL works, it basically does pattern matching and uses that to process node sets. So you basically have 2 patterns, rows of users and columns of statuses. Getting the rows is easy (i.e. the default), but for the columns you need a second pattern: the distinct set of statuses.

I would go about this by performing the following steps:

first selected the distinct set of status, this nodeset will be used to build the per user column set

iterate over the rows, grouped by user (i.e. an xsl template) using the Muenchian method (you can't use xslt 2.0's for-each-group since SharePoint uses xsl 1.0) per grouped nodeset, build the columns matched against the previously defined distinct set of statuses, surround the entire thing with an xsl:choose to only show the username in case there is no set of documents for this user's row.

In short, you can just build a regular table for the user rows, and have each row include a table when the user has documents and have this table's column's consist of the statuses.

end html result:

<table>
  <tr>
    <th>username</th>
    <th>status 1</th>
    <th>status 2</th> <!-- build the status headers from the set of status -->
  </tr>      
  <tr>
    <td>user 1</td>
    <td>
      <table>
        <tr>
          <th>user status 1 **count**</th>
          <th>user status 2 **count**</th>
        </tr>
        <tr>
          <td>user status 1 doc</td>
          <td>user status 2 doc</td>
        </tr>
        <tr>
          <td>user status 1 doc</td>
          <td>user status 2 doc</td>
        </tr>
      </table>
    </td>
  </tr>
 <!-- etc... -->
</table>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.