Friday, February 8, 2013

Query filter webpart in Sharepoint 2010

A demo on how to use the Query filter webpart of Sharepoint 2010.

The "Filter" feature of Sharepoint 2010 is available to you only when you activate the

SharePoint Server Enterprise Site Collection features

which is available only with the Enterprise version installation .

It is used mostly in the requirements mentioned below

  • You have a home page where there are number of links, on click of this it should redirect to new page where the data is displayed based on the option which is clicked in the home page

Process followed to achieve this requiremenst are
1)Create home page and add a content editor webparts
2)Add few anchor tags redirecting to the next page which we will be customizing
3)In the new page Edit Page -->Add a list view webpart also a Query filter webpart.
4)Now in the Page edit mode itself .Click on the edit webpart option of Query filter webpart
Now Add a Paramater say "parm" in the paramater name option .
You can try other oprtions in the menu too ,but I am gonna demo only the simple one
5)Now in the edit mode of page ,Click on the drop down option of  list view webpart which is found on the top right corner of each webpart
6)Select Connections-->Get filter value from -->Select the Query filter option
7)A pop up menu opens Select the field which you want to filter by the "parm" click finish 
8)Now go to the home page edit those anchor tags created in step 2 add query string like 
Eg : testsite/SitePages/DisplayQueryFilter?parm=1


So when to click the anchor tag the page is redirect to say DisplayQueryFilter with query string as "parm=1" for first tag
Now since we have set the paramter name as "parm" in Queryfilter webpart it pulls the value as 1 for above mentioned tag.

This value "1" is used to filter the list below since we set up a connection between the two webparts.



Friday, February 1, 2013

Modal Popup in Sharepoint by javascript

Most come requirement in Sharepoint custom developemt is to have a popup .This can be achieved by using the Modal PopUp .Below is the code script which gives us popup in sharepoint


<script type=”text/javascript”>

function OpenDialog(URL) {
     var options = SP.UI.$create_DialogOptions();
     options.url = URL;
     options.width = 600;
     options.height = 400;
     SP.UI.ModalDialog.showModalDialog(options);
}

</script>

<a href=”javascript:OpenDialog(‘URL of the page to be displayed here’)”>Link</a>


You can use this script in a .js file reference it anywhere in the sharepoint site and you should be able to call the function .