This project has moved and is read-only. For the latest updates, please go here.

Working with wiki pages and filtering is not returning correctly for DVWP display form

Mar 28, 2013 at 11:35 AM
I am building a DVWP / Display form for an Enterprise Wiki to display comments on the pages they are entered on following and have set the DFWP as close to the sample code he provides as I can, with the exception of being able to set the query strings variables the way he directs because of the Pages Library set-up. All fields are populating the way they should, I just can't get the filtering to work.

I have run into issues with filtering the Display form according to the page the form is present on because of multiple levels of folders involved in the Pages Library and likely other complications that come with working with the Enterprise Wiki. I have been unable to find a Query String Variable or filter combination that will display any results.

I have used jQuery to re-create the Name Field, but it won't accept it as a way to filter due to the folders.

I have the page ID, through use of the SharePoint:ListItemsProperty Control, however, it won't filter based on that value (I think because of the field formatting being inconsistent when I pass it through the new item form).

Is there a way to filter it directly with Javascript or jQuery? I am new to code and using query strings, both, all my experience previously has been doing everything OOB.

I am doing all my work in SPD, I am unable to import solutions/ features into the the site collection due to issues regarding company policy and managed code.

So, any ideas or a simple way to get the filter to work?

Here is my webpart code:
         <ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
         <ParameterBinding Name="ManualRefresh" Location="WPProperty[ManualRefresh]"/>
         <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
         <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
         <ParameterBinding Name="ListID" Location="None" DefaultValue="{69E762CE-929B-41CC-A4A2-F87C7DBF149F}"/>
<DataFields>@Title,Title;@Author,Created By;@Editor,Modified By;@PageID,PageID;@PageTitle,PageTitle;@Comments,Comments;@_Author,Author;@Workflow_x0020_Name,Workflow Name;@NotficationSent,Notfication Sent;@NotificationRecipient,Notification Recipient;@PageID_x003a_Contact_x0020_Name,PageID:Contact Name;@PageID_x003a_Title,PageID:Title;@IDLinkingField,IDLinkingField;@ID,ID;@ContentType,Content Type;@Modified,Modified;@Created,Created;@_UIVersionString,Version;@Attachments,Attachments;@File_x0020_Type,File Type;@FileLeafRef,Name (for use in forms);@FileDirRef,Path;@FSObjType,Item Type;@_HasCopyDestinations,Has Copy Destinations;@_CopySource,Copy Source;@ContentTypeId,Content Type ID;@_ModerationStatus,Approval Status;@_UIVersion,UI Version;@Created_x0020_Date,Created;@FileRef,URL Path;@ItemChildCount,Item Child Count;@FolderChildCount,Folder Child Count;</DataFields>
<xsl:stylesheet xmlns:x="" xmlns:d="" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="" xmlns:asp="" xmlns:__designer="" xmlns:xsl="" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
    <xsl:output method="html" indent="no"/>
    <xsl:decimal-format NaN=""/>
    <xsl:param name="dvt_apos">&apos;</xsl:param>
    <xsl:param name="ManualRefresh"></xsl:param>
    <xsl:param name="ListID">{69E762CE-929B-41CC-A4A2-F87C7DBF149F}</xsl:param>
    <xsl:variable name="dvt_1_automode">0</xsl:variable>
    <xsl:template match="/" xmlns:x="" xmlns:d="" xmlns:asp="" xmlns:__designer="" xmlns:SharePoint="Microsoft.SharePoint.WebControls">
            <xsl:when test="($ManualRefresh = 'True')">
                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                        <td valign="top">
                            <xsl:call-template name="dvt_1"/>
                        <td width="1%" class="ms-vb" valign="top">
                            <img src="/_layouts/images/staticrefresh.gif" id="ManualRefresh" border="0" onclick="javascript: {ddwrt:GenFireServerEvent('__cancel')}" alt="Click here to refresh the dataview."/>
                <xsl:call-template name="dvt_1"/>
    <xsl:template name="dvt_1">
        <xsl:variable name="dvt_StyleName">RepForm3</xsl:variable>
        <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row "/>
        <xsl:variable name="dvt_RowCount" select="count($Rows)"/>
        <xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" />
        <xsl:variable name="dvt_IsEmpty" select="$dvt_RowCount = 0"/>
            <xsl:when test="$dvt_IsEmpty">
                <xsl:call-template name="dvt_1.empty"/>
                <table border="0" style="width: 64%">
                    <xsl:call-template name="dvt_1.body">
                        <xsl:with-param name="Rows" select="$Rows"/>
    <xsl:template name="dvt_1.body">
        <xsl:param name="Rows"/>
        <xsl:for-each select="$Rows">
            <xsl:call-template name="dvt_1.rowview" />
    <xsl:template name="dvt_1.rowview">
                <table border="0" cellspacing="0" style="width: 100%">
                    <td style="text-align:right;width:8%"><xsl:attribute name="border">1px #bfbfbf</xsl:attribute>
                            <xsl:attribute name="padding">1px</xsl:attribute>
                            <img border="0" src="{@Editor.picture}" width="35" height="40" style="float: right" /></td>
                    <td  class="ms-vb" style="width: 22%">
                    <xsl:value-of select="@Author" disable-output-escaping="yes" />                 </td>   
                    <td  class="ms-vb" style="width: 25%">
                            <xsl:value-of select="@Created" />
                        <td class="ms-vb" style="width:45%"><xsl:value-of select="@Comments" /></td>                        </tr>
                    <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
                            <td colspan="99" class="ms-vb">
                                <span ddwrt:amkeyfield="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(@ID))" ddwrt:ammode="view"></span>
    <xsl:template name="dvt_1.empty">
        <xsl:variable name="dvt_ViewEmptyText">There are no items to show in this view.</xsl:variable>
        <table border="0" width="100%">
                <td class="ms-vb">
                    <xsl:value-of select="$dvt_ViewEmptyText"/>
Here is how I populate it (recommendations on better methods appreciated)
<script type="text/javascript" src="/Style Library/scripts/jquery.SPServices-0.7.1a.min.js"></script>

<script type="text/javascript">
// File to set Filters and html for wiki page comments web part must load last

// Limit characters
    function limitChars(textid, limit, infodiv){
        var text = $('#'+textid).val();    
        var textlength = text.length;
            if(textlength > limit) {
            $('#' + infodiv).html(''+limit+' limit reached');
            return false;
            else {
            $('#' + infodiv).html(''+ (limit - textlength) +' characters left');
            return true;
            //set character Limit
        $(".FormFieldNewsComments > span > textarea[title='Comments']").keyup
        {limitChars(".FormFieldNewsComments > span > textarea[title='Comments']", 300, "LimitInfo");
            //Set form fields
    $(document).ready(function() {
        var fileloc = location.pathname.substr(17) // Get the page filename
        var PageTitle = $('.wikipagenamediv').html(); // Get the page title
        var PageTitleT = $.trim(PageTitle);
        var PageIDvalue = _spPageContextInfo.pageItemId;
    $(".FormFieldNewsTitle > span > input[title='Title']").val(fileloc); // insert page filename in a CSS hidden formfield
    $(".FormFieldPageTitle > span > input[title='PageTitle']").val(PageTitleT); // insert pages title in a CSS hidden formfield
    $("select[title='PageID']").val(PageIDvalue); // If less than 20 items i Pages bibl, lägger in ID nr som en selected i DD
    $("input[title='PageID']").val(PageIDvalue);  // If 20 or more items in Pages lib
      operation: "GetListItems",
      async: false,
      listName: "{0d1170bb-5edb-46b8-924c-7f5f369e1a83}", //wiki library GUID
      CAMLViewFields: "<ViewFields><FieldRef Name='Comments' /><FieldRef Name='PageTitle' />",
      CAMLQuery: "<eq><fieldref Name='PageID'/><value Type='Text'>_spContext.pageItemId</value></eq>",
      completefunc: null, 
        debug: true });
Mar 28, 2013 at 2:33 PM
So trying to get at the nut of this, is it that the filter
      CAMLQuery: "<eq><fieldref Name='PageID'/><value Type='Text'>_spContext.pageItemId</value></eq>",
isn't giving you back the content you want?

I notice that you are making the call to GetListItems, but you're not doing anything with the results.

Mar 28, 2013 at 4:36 PM
Edited Mar 28, 2013 at 7:50 PM
This is where the noob issues start to shine through. I was unsure how to write it back to the CAML for the view. I've never worked with JS or jQuery before this week and this was as far as I was able to figure out how to get from what I've pieced together over the last week or so.

And, yes, I read the documentation. This is as far as I got with what I could understand in a week, lol.

Apr 2, 2013 at 10:01 PM
Edited Apr 3, 2013 at 2:26 PM
Take a look at some of the examples in the documentation to see how to handle the returned data. Your completefunc is null, so you're not doing anything with the results. You'll probably want to loop through the returned items and build up some markup to insert into the page.

Apr 5, 2013 at 12:27 AM
Edited Apr 5, 2013 at 12:29 AM
I ended up doing it all via CQWP because I couldn't figure out how to pass the URL through and was able to set up everything through itemstyle.xsl to look almost duplicate to the Note Board Web Part. Now the project is ccompete, I can take some time and read through more of the awesome work you and other folks share on this discussion board.
Apr 5, 2013 at 1:45 AM
Edited Apr 5, 2013 at 1:45 AM
I'm not sure what you mean by passing the URL through, but it sounds like you solved the immediate problem, so great.