Saturday, August 24, 2013

Hide Upload,Multiple, Add Document link from library view for DocSet

The requirement is that to avoid user to create, edit and delete docset, but they can add, upload, edit document inside the Doset. Also, avoid user to add document outside the Docset. 

So for the above requirement, i had created css file and uplaod it to style library and add the path of file path on library view page, where docset available. The css available in my file is as below:-

TD.ms-addnew
{
DISPLAY: none !important
}
#Ribbon\.Documents\.New\.AddDocument-Large
{
display:none;
}
#Ribbon\.ListItem\.New\.NewListItem-Large
{
    display:none;
}
#Ribbon\.Documents\.New\.NewDocument-Large
{
   display:none;
}
#Ribbon\.Documents\.Manage\.EditProperties-Large
{
  display:none;
}
#Ribbon\.Documents\.Manage\.Delete
{
  display:none;
}
#Ribbon\.Documents\.Manage
{
  display:none;
}


and add the below javascript inside the doset page to hide the "View All Properties" and  "Edit All Properties".

<script language="javascript">
_spBodyOnLoadFunctionNames.push("HideShow");
 function HideShow()
{

   var EditProperties = document.getElementById ('EditPropsLink');
if(EditProperties != null)
{
   EditProperties.style.display = "none";
}
var ViewProperties = document.getElementById('ViewPropsLink');
if(ViewProperties != null)
{
 ViewProperties.style.display = "none";
}


}
<script/>
Happy coding..... :-)

Expand only the first group and have the rest of the groups collapsed in Dataform webpart SP 2010

Now, it is possible in DVWP to expand only the first group and have the rest of the groups collapsed.
Example:-
- Group: Year 2013
- Item 1
- Item 2
- Item 3
+ Group: Year 2012
+ Group: Year 2011
+ Group: Year 2010

Use the following steps:-

1) Create dataform webpart using Sharepoint designer and bydefault group is collapsed in dataform webpart.
2) Save the page and search webpart id for dataform webpart in view source of page. E.g In my case it is  MSOZoneCell_WebPartWPQ4. Search the id for div available in webpart, <div id="WebPartWPQ4".
3) Use the following script on page and replaced the WebPartWPQ4   with your dataform webpart div id.
<script src="https://Server/SiteName/Style%20Library/Custom%20Javascript/jquery-1.8.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
functioncollapseGroups() {
var someimage = document.getElementById('WebPartWPQ4');     //Webpart Id available in div tag
var myimg = someimage.getElementsByTagName('img')[0];     //  It will check first group image(+) available in div tag
var mysrc = myimg.src;
   //alert(mysrc);
    //$("img[src='/_layouts/images/plus.gif']:visible").parent().click();
    $(myimg).parent().click();
}
_spBodyOnLoadFunctionNames.push("collapseGroups");
</script>

The script will find 1st + sign image available next to group first and forcefully fired the click event.

Bingo!!!!, the script is work properly and our issue resolved.