I have a content query web part showing 3 events for todays date on our Intranet homepage. However, when a user deletes an event from a recurring series, SP changes the title of that event to "Deleted: [original title]". My content query web part still shows these and I don't see a way to filter them out.
For my list views I get around it with a field and a formula in that field of the following.
=IF(ISNUMBER(FIND("Deleted:",Title)),"Yes","No").
However, that field isn't available to me within the CQWP filter drop-down.
how does one prevent these deleted occurrences from showing in a CQWP?
UPDATE: This is a publishing page BTW.
While you can perform the filter via XSLT, it may be preferable to do so in the CAML query itself. This article from Microsoft, How to: Customize the Content Query Web Part by using Custom Properties, shows how the CAML Where clause is constructed (and may be modified). Good luck!
Have you tried the DataFormWebPart (DFWP) before? It is basically the most basic of databound webparts, but strangely the most customizable as well.
To try it out, open SharePoint designer and create a dummy aspx page to work on / play around with. Then open the datasources pane and find the list you want to use. then click on that list and select "view data". Drag the appropriate fields onto the aspx page. You now have a (very) basic grid displaying your data.
The cool thing is though, all layout is xsl driven, so completely customizable. You can even make the xsl reusable by switching to source view and cut and paste the xs,l into a separate xsl file. To then use this file instead of the inline xsl, after moving the inline xsl, change the DFWP property xsl (that contained the inline xsl) from
<xsl><!-- .... this is where the moved inline xsl used to be... --></xsl>
to
<xsllink>/server relative url to xsl file</xsllink>
The only remaining problem is that the DFWP's datasource is now bound a single list. To do roll-ups cross site collection (if you have say multiple event lists you want to include), you need to change the DFWP's SPDataSource's select query and datasourcemode. How to do that is explained here.
Now to address your actual question: (after my blatant plug of the underappreciated DFWP :-D) The DFWP's SPDataSource basically uses either an SPQuery or an SPSiteDataQuery (depending on the datasourcemode) to retrieve the data, and you can do way more filtering wise. Either in the CAML query itself or by just filter out the unneeded rows using something like the following:
<xsl:if test="not(contains(#Title, 'Deleted:'))">
<xsl:apply-templates />
</xsl:if>
Related
I want to filter my sharepoint list based on what letter / number a row starts with. I know I can do this by adding a new calculated column and filter on that but I would love to be able to filter solely using the URL or JavaScript without adding a column for only that purpose. Any advice?
You can't do this just through the URL. SharePoint accepts FilterFieldxxx and FilterValuexxx querystring parameters, but they only filter exact values.
You could do it programmatically using xslt in a list view. You could also use JavaScript to call an API like Web services, listdata.svc, the JSOM, or _api (new in SP 2013). But honestly the calculated column seems to be the most solid and straightforward approach.
You can add a Content Editor webpart to your view form using SharePoint Designer and put in some jQuery to filter the list based on a querystring value.
Upload the jQuery files to your style library and add the javascript to your content editor webpart.
note that it will be hard to get this right as the querystring is extensivley used in views and views are very flexible and allow someone to completely redesign the output html, just by adding in a group by clause to the view or even remove your title field.
I am trying to create a Page Layout, that should have a lookup field. Lookup field should always get populated with a list's items.
This list will exist in all subsites, so whereever I create this page, list should get populated with listitems from current site.
I tried using site column lookup field, but it always point to list under top site and not the current site.
Any suggestion on how to make it work or better alternative? Thanks!
Let me know if I can provide more info.
The most straightforward solution I can think of is using a cross site lookup column and creating a seperate fields for each subsite. However, you will need to create and use different Page Layouts for each subsite.
You can use http://sp2010filteredlookup.codeplex.com/ for cross site lookups.
Solution 1 - Use http://sp2010filteredlookup.codeplex.com/
Use filtered lookup solution. So let's say you have your custom Page Layout and custom Page Content Type.
Every time you create new subsite, you should remember go to Pages list settings and edit Page Content Type by adding cross site lookup (with the same field "internal name").
So you still have one Page Layout (and one Content Type). But for each Pages library instance, Content Type contains diff fields (but with the same Internal Name). It will allow you run CAML queries and other things needed without any problems.
Solution 2 - develop custom sharepoint field type.
In edit mode, control will render "dropdown list" and populate data from list instance that is on current subsite. In the field settings you can have relative list url.
Solution 3 - hidden text field / js snippet solution
Page Content Type can contain hidden text field (it can contains selected field value in json format for example). Develop js snippet that will handle all the logic (rendering in edit/view mode, saving etc) and put it on Page Layout (aspx).
I would suggest to use solution #1 or #2.
short: A listview webpart contains a table with an ID composed of two GUID's, how do I find these?
I am working on adding some additional behaviour to a standard sharepoint listview-webpart.
Preferably I don't want to actually edit the webpart itself. I want to put javascript in a helper webpart to add some onclick events to the table rows which pass the values of the id and status columns to the helper webpart, which then displays some buttons depending on the row's status.
I searched around to see how others tackled this problem, and usually they use the webpart container div with ID WebPartWPQ _n_". The problem is that these webparts are going to be used on lots of sites, and I have no way of knowing the value of _n_.
A bit further down in the hierarchy is the main table of the view, and it also has an ID. In my test-case: {BF3FB0FA-7E7F-4920-A326-B5E46826B693}-{BD0777BD-455D-4554-A80E-8A11D990D1A5}
I figured these two guids must stand for something and could possibly be looked up.
So I went on a search through Sharepoint Manager to try to find those GUIDs, but I can't find them. Neither is the list ID, nor the original View ID, nor the web ID or the site ID.
So my question: Does anybody know what these ID's stand for, and how I can find them with my webpart code?
Have you considered using XSLT to customize the output of the webpart? You could then customize the output HTML and include any identifiers you wish so that you could reference them in your javascript. This is a pretty good description of how to do this: Overriding the presentation of an XSLT List View Web Part.
I have a Content Query Web Part on my page that rolls up all the contacts lists from all the sub-webs in my site collection. this works fine. I'd like to be able dynamically filter the contacts rollup by having the user click on a list of leters of the aphhabet at the top of the page. click A and see the contacts that start with A, etc...
I'm plopping various filter web parts on the page, but don't see how to filter the results of the CQWP. The connections menu is not much help.
You can't use the OOB filter webparts or CQWP like that.
What you can do is extend the CQWP and add some functionality to it - take a look at Enhanced Content Query Web Part over at codeplex.com for inspiration.
Then send the clicked letter to the QueryString and have your extended CQWP read the filter value from the querystring - this would perform really well
Generally, this sort of thing requires some development. Here's one source:
http://www.andrewconnell.com/blog/archive/2008/02/18/Subclassing-the-Content-Query-Web-Part-Adding-Dynamic-Filtering.aspx
i would not recommend you to use a cqwp....instead try using a dataview web part it allows you to filter the content using querystring parameters without coding.
let me explain my current situation
i have a SharePoint site lets say it is MAIN, and a subsite lets call it SUBMAIN
in MAIN i have a list called "a" and in subMAIN i have a list called "b"
both lists have the exact same columns,
i need to show the content of both lists (ordered by modified date for example) in one webpart in the main page i know it is possible some how but couldnt get to it.
currently i am showing only the content of list "a" in a content query webpart (i have changed the way it display and added to it horizontal merquee) so it will be nice if somehow i can add contents of list"b" also to the same content query webpart (but if it is not possible in content query webpart its ok, at least let me know what other options do i have)
your help is appreciated
If you are using SharePoint Designer to do this, take a look at this blog.
If you are building your own web part, I would perform two queries on the SPList objects. You can then aggregate, sort, etc. the results however you would like. If you aren't familiar with SPList, you can look here for the MSDN overview.
I've built web parts to display items from 2 different lists, and I did something similar to what Scott Price suggested. I used an SPQuery object for each list and used it to get DataTable objects that I could then use with things like Repeaters and DataLists. You could merge your two tables and do something similar.
The biggest trick for me was setting up the custom templates for DataBinding in a webpart. To do that, I created a custom class that implemented the ITemplate interface and then emitted the HTML for each item from the template class in an event handler. Then, you just create an instance of your template class and set that as the ItemTemplate property of your, say, DataList.
This post and this one do a better job of explaining that approach, but the nice thing is that you have complete control of the markup, and you can style it as you like.
If you're not looking to code your own solution, you might consider this webpart on codeplex:
http://rssaggregator.codeplex.com/
It's actually an RSS aggregator, but since all SharePoint lists have built-in RSS feeds, you can use it just as well to aggregate the SharePoint lists from the different sites.
Another approach is SLAM, SharePoint List Association Manager, an open source project my company created and actively supports. SLAM will allow you to configure those two lists to be automatically synchronized to SQL tables at which point you can create a query to join the two. If you have the two lists built off a content type (since they have the same fields) you can actually slam the content type and have both lists in the same SQL table.