We know built in search functionality in SharePoint. When configured properly, you can search from entire site just anything and search will categorize the results for you.
However a simple scenario came to me last week. When you are on any list AllItems.aspx page and if you have observed, by default search scope on top right is set to “This site: {site name}”.
This List: {list name} by default instead of This Site: {site name} so that they directly can put in words and search from that list.
So go ahead and open view source of the page, search for This List: {list name} and take out its ID. It should be ending with SBScopesDDL.
And add content editor web part on AllItems.aspx and paste the following code. Do not forget to reference correct jQuery js location.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" >
$(document).ready(function() {
//Below function makes sure that if the status is not suspended in edit mode, it disables the reason text //area
var text = $("select[title$='Search Scope'] :selected").text();
$("#ctl00_PlaceHolderSearchArea_ctl01_SBScopesDDL").val("This List: YOUR LIST NAME ");
});
</script>
</script>
And you are good to go. Observe the top search box, you will find by default This List : {list name} selected.
1 comment:
Sweet. Exactly what I was looking for - that easy. Thanks for sharing.
Post a Comment