Supporters of End User
Web

SharePoint DVWP Filter Toolbar: Remove Filterability on Columns

Item is currently unrated. Press SHIFT+ENTER to rate this item.1 star selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+ESCAPE to leave rating submit mode.2 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.3 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.4 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.5 stars selected. Press SHIFT+ENTER to submit. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.
Categories:MOSS; WSS; 2007; 2010; Site Manager/Power User; SharePoint Designer; Data View Web Part

Dave recently submitted the following question on MSDN forums:

Hi all,

Using: WSS 3.0, SharePoint Designer 2007

I have created a DVWP to display data from a custom list on a site and this is working great for the most part. However, I have a query regarding the DVWP filtering:

I have turned on the toolbar to display the filter options and when I click the filter icon, I can see all of my columns listed - so far so good. The issue I have is that I want to cut this down to only show 2 of the columns available (I currently have 10 columns).

Anyone know how to customise this?

Cheers. Dave.

The great thing about the DVWP is that it's just XSL. XSL is what tells the browser what to draw in HTML, so you can go in and remove any of the columns you don't want the user to filter by.

At the top of your stylesheet, find:

<xsl:param name="dvt_adhocmode" />

...and change it to:

<xsl:param name="dvt_adhocmode">filter</xsl:param>

When you click in the Code pane again, you will see all of your filters.

Now you can click on one of the selects to see where they're drawn. When you do, you'll see they're all drawn with the same piece of XSL inside the dvt.filterfield template. If you search for where those are called, you can strip out the ones you don't want.

For example, if you don't want the user to have the ability to filter on "Manager," find:

<th nowrap="nowrap">
    <table>
        <tr>
            <td class="ms-toolbar" nowrap="nowrap">
                <xsl:call-template name="dvt.filterfield">
                    <xsl:with-param name="fieldname">Manager</xsl:with-param>
                    <xsl:with-param name="fieldtitle">Manager</xsl:with-param>
                    <xsl:with-param name="Rows" select="$Rows" />
                    <xsl:with-param name="fieldtype">text</xsl:with-param>
                </xsl:call-template>
            </td>
        </tr>
    </table>
</th>

...and replace it with:

<th nowrap="nowrap" valign="top">Manager</th>

Or delete the entire TH, depending on how you want it to look. The last TD in that TR has a width of 99%, so it will fill in the gap if you delete one (or more).

2010-11-16-DVWPFilterToolbar-02.png

Note: Be sure to reset the dvt_adhocmode before saving if you don't want the filter toolbar to display by default. But, that's an additional feature to know: if you leave that set to filter, you can have the filter toolbar display by default.

Comments

Notify me of comments to this article

E-mail:
   

Add Comment

Title:

 
Comment:
Email:

   


Name:

 
Url: