Showing posts with label List View. Show all posts
Showing posts with label List View. Show all posts

August 2, 2017

SharePoint List View Web Part - Open documents in new browser tab

Scenario:
I wanted to show documents stored in a Document library, on a page with the help of  List View Web Part. I added List View web part and configured the same to display documents from a document library. Everything looked good apart from one thing. I wanted documents to open up in a new tab. But, instead, documents were opening in same tab.  

If there had been navigation links just thrown up on the page without any web part, I would have just added target="_blank" attribute. But, here, I had used Listview web part. So, I was compelled to come up with a different solution. A solution that should be working without jeopardizing the page view and other functionalities. I kept on turning over different solutions until I ran across a solution that looked easy and could be carried out with minimum efforts. I added a content editor web part and punched in my code into it. Saved the page and clicked on the document. And as expected, It didn't let me down.

Solution: Here, I am sharing the steps that I've performed to rid myself of that issue:

Step 1:
Click on Edit page from Site Settings Gear icon.
 

Step 2:
Now, Click on Add a web part.

Step 3:
Seek "Media and Content" and add "Content Editor" web part.  It should be on the top in the all web parts listed in Media and Content gallery.

Step 4:
Once web part has been added, click on "Click here to add content".

Step 5:
You should see "Format Text" ribbon and in that ribbon, You should see "Edit Source".

Step 6:
Click  on Edit Source and tap this code into that window. Click on OK.
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js" type="text/javascript" />  
 <script type="text/javascript">  
 $(document).ready(function(){  
   $('#onetidDoclibViewTbl0 a').removeAttr('onclick').attr('target', '_blank');}  
 );  
 </script>  

 
Step 7:
 Now, go to Edit Web Part menu and change appearance settings to hide title and chrome for this web part.

Step 8:
Click on Stop Editing to save the page.

Step 9:
Check it in and publish it.

Step 10:
Now, Click on a document name and it should be opening in a new browser tab.

If you have any questions you can reach out our SharePoint Consulting team here.

August 12, 2016

SharePoint List View: Filter by Me and My SharePoint Groups

Scenario 
I have a SharePoint List containing task items. Tasks are assigned to a specific SharePoint Group or individual user. Each group has its own members. Requirement is, if current user is member of any of those groups, can see assigned tasks under My Tasks View.

Approach
There are few possible solutions, one of them is to modify Query filter via SharePoint Designer.

Filtering a list view by group membership
Step: 1
Open SharePoint designer then open site.  Select the Task List under Lists and Libraries. (For example, here we have selected "ResourceDocumentTypes").


Step: 2
When you select task list you will see a panel on right side named "Views". Select the view that needs to be modified. (For this example it’s "My Events")







Step: 3
Note: If you cannot edit file, you must select advanced mode.

In source view, search for <Query> and you will see View Query. If you have already modified view as filtered by [Me]. In that case, you need to modify the query which contains

<Query><Where><Eq><FieldRef Name="AssignedTo"/><Value Type="Integer"><UserID 

Type="Integer"/></Value></Eq></Where></Query>

With below code:

<Query>
<Where>
<Or>
<Membership Type="CurrentUserGroups"><FieldRef Name=" AssignedTo"/>
<Membership>
<Eq>
<FieldRef Name="AssignedTo"/><Value Type="Integer"><UserID Type="Integer"/></Value>
</Eq>
</Or>
</Where>
</Query>

Be sure to change the "FieldRef Name" to your own field, and click Save. Done!

Now, User can see all task items where “AssignedTo” field contains a SharePoint Group that logged in user is a member of and also assigned to him/her directly.

Results
Here is a list view showing all tasks assigned to different SharePoint Groups:

Below is filtered list view showing only tasks assigned to SharePoint Groups for which current user is a member.


If you have any questions you can reach out our SharePoint Consulting team here.