Stump the Panel: SharePoint Q&A

Immediate solutions for common SharePoint questions
It is currently Sat May 25, 2013 4:39 am

All times are UTC - 5 hours [ DST ]


Forum rules


What you are viewing is an archive of Stump the Panel. It remains for reference purposes. Please post all new questions on NothingButSharePoint.com
https://www.nothingbutsharepoint.com/sites/eusp/Forum



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 20 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Displaying data from 2 list collections
PostPosted: Mon May 16, 2011 3:14 pm 
Offline
User avatar

Joined: Sat Jan 02, 2010 4:29 pm
Posts: 589
Location: Boston, MA, USA
It's exactly the same in 2010.

I'm not sure exactly where you are and what code you have at this point. Can you post the skinny version of your XSL? (i.e., not all of it; just the relevant pieces.)

M.


Top
 Profile  
 
 Post subject: Re: Displaying data from 2 list collections
PostPosted: Mon May 16, 2011 3:27 pm 
Offline
User avatar

Joined: Mon Jan 04, 2010 1:15 am
Posts: 1839
Location: North Carolina
This is the meat. It's selecting everything from my lists and right now is showing everything from the Lab list dsqueryresponse. I'm only outputting 2 fields into my output until I can get the filter thing sorted out at which point I'll introduce a subview.
Code:
   <DataSources>
      <SharePoint:AggregateDataSource runat="server" IsSynchronous="false" SeparateRoot="true" id="Labs_x0020_and_x0020_Requests1"><sources><SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" selectcommand="&lt;View&gt;&lt;/View&gt;"><SelectParameters><asp:Parameter Name="ListID" DefaultValue="{4F988F8A-336E-4154-B045-D083FA0371A1}"/></SelectParameters><DeleteParameters><asp:Parameter Name="ListID" DefaultValue="{4F988F8A-336E-4154-B045-D083FA0371A1}"/></DeleteParameters><UpdateParameters><asp:Parameter Name="ListID" DefaultValue="{4F988F8A-336E-4154-B045-D083FA0371A1}"/></UpdateParameters><InsertParameters><asp:Parameter Name="ListID" DefaultValue="{4F988F8A-336E-4154-B045-D083FA0371A1}"/></InsertParameters></SharePoint:SPDataSource>
         <SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" selectcommand="&lt;View&gt;&lt;/View&gt;"><SelectParameters><asp:Parameter Name="ListID" DefaultValue="{A7CDE259-0D93-490B-B73B-D738B4510FE6}"/></SelectParameters><DeleteParameters><asp:Parameter Name="ListID" DefaultValue="{A7CDE259-0D93-490B-B73B-D738B4510FE6}"/></DeleteParameters><UpdateParameters><asp:Parameter Name="ListID" DefaultValue="{A7CDE259-0D93-490B-B73B-D738B4510FE6}"/></UpdateParameters><InsertParameters><asp:Parameter Name="ListID" DefaultValue="{A7CDE259-0D93-490B-B73B-D738B4510FE6}"/></InsertParameters></SharePoint:SPDataSource>
      </sources><aggregate><concat name="data source"><datasource name="Requests" id="0" Type="SPList"/><datasource name="Labs" id="1" Type="SPList"/></concat></aggregate></SharePoint:AggregateDataSource>
   </DataSources>
   <ParameterBindings>
                  <ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
                  <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
                  <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
                  <ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
                  <ParameterBinding Name="dvt_nextpagedata" Location="Postback;Connection"/>
               </ParameterBindings>
   <datafields>Cut out for brevity</datafields>
   <XSL>
<xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 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">'</xsl:param>
   <xsl:param name="dvt_firstrow">1</xsl:param>
   <xsl:param name="dvt_nextpagedata" />
   <xsl:param name="UserID">CurrentUserName</xsl:param>
   <xsl:variable name="dvt_1_automode">0</xsl:variable>
   
   <xsl:template match="/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls">
      <xsl:call-template name="dvt_1"/>
   </xsl:template>
   
   <xsl:template name="dvt_1">
      <xsl:variable name="dvt_StyleName">Table</xsl:variable>
      <xsl:variable name="Rows" select="/dsQueryResponse/Labs/Rows/Row"/>
      <xsl:variable name="dvt_RowCount" select="count($Rows)" />


As soon as I apply a filter to my Row variable, save, and refresh the bare DVWP, it returns no results when it should be returning 1 row.


Top
 Profile  
 
 Post subject: Re: Displaying data from 2 list collections
PostPosted: Mon May 16, 2011 3:32 pm 
Offline
User avatar

Joined: Sat Jan 02, 2010 4:29 pm
Posts: 589
Location: Boston, MA, USA
So what are you doing when you apply the filter?

If you only want the labs for the current user, you can add that filter into the CAML in the selectcommand for the Labs list. Then when you add the subview, you'll only get the items from Requests which have a "parent" Lab.

M.


Top
 Profile  
 
 Post subject: Re: Displaying data from 2 list collections
PostPosted: Mon May 16, 2011 3:42 pm 
Offline
User avatar

Joined: Mon Jan 04, 2010 1:15 am
Posts: 1839
Location: North Carolina
Going into the Common Data View Tools dialog and selecting Data Owner = $UserID which outputs the Row variable as:
Code:
<xsl:variable name="Rows" select="/dsQueryResponse/Labs/Rows/Row[@Data_x0020_Owner = $UserID]"/>


I've also tried to enter it manually and strip out all the html markup from the person/group column.
Code:
<xsl:variable name="Rows" select="/dsQueryResponse/Labs/Rows/Row[substring-before(substring-after(@Data_x0020_Owner, 'ID='), '&quot;') = $UserID]"/>


As soon as I apply either of these, the data view returns no data when it's saved and refreshed. Even a basic ascending sort on one of the columns that is being output in the data view does not sort at all. Most of this is evident in several of the other forums and blog posts I'm seeing. It's fine if you only need to display information but as soon as you need to do any sorting and filtering, it doesn't work right.

I've seen the suggested fixes about removing junk code it will output and as far as I can tell, I've removed it all.


Top
 Profile  
 
 Post subject: Re: Displaying data from 2 list collections
PostPosted: Mon May 16, 2011 3:51 pm 
Offline
User avatar

Joined: Sat Jan 02, 2010 4:29 pm
Posts: 589
Location: Boston, MA, USA
I build DVWPs like this all the time, so I'm 100% positive you can do it. Explaining it is another matter!

So if you switch from
Code:
<xsl:variable name="Rows" select="/dsQueryResponse/Labs/Rows/Row"/>
to
Code:
<xsl:variable name="Rows" select="/dsQueryResponse/Labs/Rows/Row[substring-before(substring-after(@Data_x0020_Owner, 'ID='), '&quot;') = $UserID]"/>
you don't get any items?

I'd display
$UserID
@Data_x0020_Owner, and
substring-before(substring-after(@Data_x0020_Owner, 'ID='), '&quot;')
in the rowview template without a filter so that I could see what values there are. This would tell me what I should expect when I filtered based on the actual data. Then I'd apply the filter and see what I got.

M.


Top
 Profile  
 
 Post subject: Re: Displaying data from 2 list collections
PostPosted: Mon May 16, 2011 4:00 pm 
Offline
User avatar

Joined: Mon Jan 04, 2010 1:15 am
Posts: 1839
Location: North Carolina
You are correct, I go from like 165 records to 0 when it should be returning 1.

When Escaped
$UserID| @Data_x0020_Owner | Substring before function
Alexander, Eric | Alexander, Eric | 131

When unescaped
$UserID| @Data_x0020_Owner | Substring before function
Alexander, Eric | <nobr><span><A HREF="/sites/submit/_layouts/userdisp.aspx?ID=131">Alexander, Eric</A>... | 131


Top
 Profile  
 
 Post subject: Re: Displaying data from 2 list collections
PostPosted: Mon May 16, 2011 4:06 pm 
Offline
User avatar

Joined: Sat Jan 02, 2010 4:29 pm
Posts: 589
Location: Boston, MA, USA
Ok, note what $UserID contains.

M.


Top
 Profile  
 
 Post subject: Re: Displaying data from 2 list collections
PostPosted: Mon May 16, 2011 4:21 pm 
Offline
User avatar

Joined: Mon Jan 04, 2010 1:15 am
Posts: 1839
Location: North Carolina
I think my frustration built up on this and caused me to rage. I replaced the Row filter with /dsQueryResponse/Labs/Rows/Row[substring-after(substring-before(substring-after(@Data_x0020_Owner, 'ID='), '&lt;'), '&gt;') = $UserID] which I know I've already tried at some point (have SPXSLT.codeplex.com open).

This returns my 1 record and I can add a subview. Now I have to work some stuff out on my subview template but I think I should be ok for the tiem being.

Thanks Marc, really appreciate the assistance.


Top
 Profile  
 
 Post subject: Re: Displaying data from 2 list collections
PostPosted: Mon May 16, 2011 4:28 pm 
Offline
User avatar

Joined: Sat Jan 02, 2010 4:29 pm
Posts: 589
Location: Boston, MA, USA
You bet! Glad you got it.

M.


Top
 Profile  
 
 Post subject: Re: Displaying data from 2 list collections
PostPosted: Mon May 16, 2011 5:33 pm 
Offline

Joined: Wed Jan 06, 2010 3:15 pm
Posts: 99
Location: Lynchburg, VA
Update - nevermind, you figured it out lol.

Eric,
If you are willing, PM me with some screenshots or email me at hornerba@gmail.com and I'll try to look at both the xsl you've been generating plus the settings you've set for your linked data source. I did find that if you change the data source's settings itself in the UI, you have to delete and re-add the dvwp to the page to get it to manage the caml correctly (so maybe that will help some). Also, is the Person/Group column you are dealing with defining specific users to own the data or groups to own it? I had to do this with a scheduling system where I wanted to display a user's classes that they registered for and provide a way to unregister to it so this gave me quite a bit of evil (even consulted Mark on it and posted my results on my blog here to give you an idea of what I had to to with the CAML: here). It definitely is possible and, in theory, possible without directly editing the CAML/XSL.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 20 posts ]  Go to page Previous  1, 2

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group