سؤال

On any list in SharePoint 2010, when you open the details view for a list item, you get presented with the display form.

If the details view for a list item contains a lookup field, it is displayed as a hyper link.

When you click this hyper link it opens in a new window.

Is there anyway to instead of opening in a new window, rather open another pop up, or even reloading the original popup?

This would make SharePoint seem more like an application rather than a web site.

Thanks in advance.

هل كانت مفيدة؟

المحلول

You can use jQuery to change the behavior. This is based off something I did 2007, but the same should hold true in 2010. It appends a target=blank attribute to any a href that ends in .msi. You'd just need to change the selector to the proper attribute for the lookup field.

<script type="text/javascript" src="/Resources/jquery.js"></script>
<script type ="text/javascript">
 $(document).ready(function(){
   $("a[href$='.msi']").attr("target", "_self"); 
 });
</script>

نصائح أخرى

The preferred approach to implementing this would be to use a custom Rendering Template.

Rendering Templates are ASCX files in the ControlTemplates folder which define how SharePoint forms are displayed in both display and edit. There are high level templates 'form' and very low level templates like 'textbox'.

For multi lookup fields there is the template 'MultipleLookupField'. You can replace this template with your own. The single lookup field does not use rendering templates and cannot be replaced using this approach directly. Instead, if you have control of the list template, you can bind the list template to a custom form rendering template (like 'ListForm') and build it out from the ground up. In effect you will need to copy over all the default templates like ListForm, ListFieldIterator, CompositeField and FormField. This would allow you to change the way a lookup field is rendered by implementing the display of the field yourself. This is a medium level investment which is totally supported.

Next, you can try and do some JQuery trickery. Works too, but it is not supportable since you are binding against non-standardized HTML structures which could change in a service pack.

To learn more about rendering templates open the DefaultTemplates.ascx in the CONTROLTEMPLATES folder. There is little information on MSDN though, but some relevant topics can be found.

Wouter

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى sharepoint.stackexchange
scroll top