June 6, 2012

Refer a SharePoint Field from Jquery

To refer a SharePoint field from Jquery use the below syntax: -
var requestId = $("input[Title='Request ID']");

The above line searches for all the input controls whose Title attribute is equal to "Request ID". Note that "Request ID" is the field name.

The variable requestId now holds a reference to the field "Request ID". If you want to hide the particular control then write requestId.hide()

Note the above will only hide the particular control and not the entire row. To hide the entire row use requestId.parent().parent().parent().hide();

Below is the complete script.
<script src="/Scripts/jquery-1.7.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var requestId = $("input[Title='Request ID']");
requestId.parent().parent().parent().hide();
});

</script>


Enjoy!!!
*****************************************************************
Free online C# tutorial. Learn easily, quickly and confidently. 
Visit today www.tutorialnode.com
*****************************************************************
Looking for cheap Business Process Management Solutions for your Business?

Visit official website of Enterprise Connections http://entconn.co.uk 
*****************************************************************

Hide columns in SharePoint 2010

Lets say you have a requirement where you want few columns to be hidden when adding/editing a new list item then you can do so by going to List Settings->Advanced Settings->Select Allow management of content types and click on OK button.

Now select the content type which is used for your list (In many cases it will be item) and in the resulting page select the column which you want to hide. In the subsequent page you can make the column hidden.

Cheers!

*****************************************************************
Free online C# tutorial. Learn easily, quickly and confidently. Visit today www.tutorialnode.com
*****************************************************************