«

»

Aug
23
2009

JQuery and SharePoint – Lookup fields and event lists

In one of my recent projects I used some JQuery to change the width of a mulitvalued lookup field in SharePoint and to hide the Workspace field in an event list.

The script to change the width of multivalued lookup fields:

<script type="text/javascript">
$(document).ready(function()
{
   $("select[id*='<INSERT_YOUR_FIELDNAME>']").parent().width(300);
   $("select[id*='<INSERT_YOUR_FIELDNAME>']").parent().height(200);
   $("select[id*='<INSERT_YOUR_FIELDNAME>']").width(300);
});
</script>

When the lookup list has a lot of similar items, it is now much easier for users to pick the right items:

image

The script to hide the workspace checkbox in an event list:

<script type="text/javascript">
$(document).ready(function()
{
   $("span[title='Workspace']").parent().parent().parent().parent().hide();
});
</script>

This first bit of script hides the ‘Workspace’checkbox in the NewForm and the EditForm. The script to hide the workspace field from the DispForm.aspx:

<script type="text/javascript">
$(document).ready(function()
{
   $("a[name='SPBookmark_WorkspaceLink']").parent().parent().parent().hide();
});
</script>

There are several ways to add the script to the pages. For the Lookup fields I used the I descibe in this blog post. For the Event list, I created custom EditForm, NewForm and DispForm pages and added the script to those pages directly.

Permanent link to this article: http://www.tonstegeman.com/blog/2009/08/jquery-and-sharepoint-lookup-fields-and-event-lists-2/

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>