- December
- 6
- 2007
DataViewWebPart / DataFormWebPart with duplicate values in Filter selection
Posted by abdrasin
No Comments »
I have a DataFormWebPart that displays Documents/List Items from 4 or 5 libraries/lists that have been modified in the past 7 days. I went to add the toolbar that allows for grouping, sorting, and filtering, not the simple one where you get to sort/filter in the column headers, but the big thick one that lets you group also.
I noticed a problem right away in that when I clicked the Filter link I got 4 different Select controls for the Title field, and a Select for a field that I don't even have in my list of columns being displayed. That was easy enough to fix-up via the Xsl. Locate the dvt_1.toolbar template and toward the bottom of it you'll find an xsl:if test on the dvt_adhocmode variable. The sections that follow determine which Selects you will see when you click the Filter link. I just removed the ones I didn't want.
The next problem wasn't so simple (for me anyway). One of the columns I chose to show in my data view was the ContentType. I noticed that in the filter options for this column that there were many options that were showing up multiple times. The list was ordered appropriately, there were just duplicate entries in it. The filter options for all the other columns in my list was fine. So I searched and searched and searched (ow!) and here's my hack to fix this. Locate the dvt.filterfield template in the Xsl and locate the following xsl:for-each statement:
<xsl:for-each select="msxsl:node-set($dvt_Rows)/*[not(@*[name()=$dvt_FieldNameNoAtSign]=preceding-sibling::*[1]/@*[name()=$dvt_FieldNameNoAtSign])]/@*[name()=$dvt_FieldNameNoAtSign]">
All I did to fix it was remove the [1], like this:
<xsl:for-each select="msxsl:node-set($dvt_Rows)/*[not(@*[name()=$dvt_FieldNameNoAtSign]=preceding-sibling::*/@*[name()=$dvt_FieldNameNoAtSign])]/@*[name()=$dvt_FieldNameNoAtSign]">
My guess is that for some reason the portion of the Xsl right before this line failed to sort properly the rows based on their ContentType attribute.