RSS Feed Feed your read!

Scot Hillier is an independent consultant and Microsoft SharePoint Most Valuable Professional focused on creating solutions for Information Workers with SharePoint, Office, and related .NET technologies. A frequent speaker at TechEd and SharePoint Connections, he is also the author many books on Microsoft technologies including 5 for SharePoint 2010. Scot splits his time between consulting on SharePoint projects and training for Critical Path Training. Scot is a former U. S. Navy submarine officer and graduate of the Virginia Military Institute. Scot can be reached at scot@shillier.com

Archives

January 2010 (17)
February 2010 (1)
March 2010 (1)
April 2010 (2)
May 2010 (1)
June 2010 (1)
August 2010 (4)
September 2010 (6)
October 2010 (3)
November 2010 (2)
February 2011 (1)
March 2011 (4)
April 2011 (3)
May 2011 (1)
August 2011 (1)
March 2012 (1)
April 2012 (1)
July 2012 (3)
August 2012 (1)
September 2012 (1)
October 2012 (2)
November 2012 (3)
January 2013 (2)
February 2013 (3)
March 2013 (3)
April 2013 (3)
May 2013 (1)
September 2013 (2)
November 2013 (5)
January 2014 (2)
February 2014 (2)
March 2014 (1)
April 2014 (1)
May 2014 (1)
July 2014 (1)

Links

IT Unity
SharePoint Team Blog
Andrew Connell's Blog

Tag Cloud

Apps, Books, Business Data Connectivity, Claims, Conferences, JavaScript, jQuery, MOSS 2007 Archived Post, PowerShell, REST and CSOM, Search, SharePoint 2010, SharePoint 2013, Web Content Management,

Change the Presentation of Fields in SharePoint 2010 External Lists 

Tags:

As Business Connectivity Solutions gain more traction, I increasingly see people trying to change the way fields are displayed in External Lists. Common complaints include the fact that Date fields always include time, or that fields presented as text should be choices. Still others want to use URL information to display an image.
 
Unfortunately, the OOB External List does not provide much built-in capability to render these special fields. The good news, however, is that there are several ways to solve the problem. Here is a list of approaches from simple to complex. I cover each of these in detail in my book Professional Business Connectivity Services.
 
Create Views and Stored Procedures in the Database
If the External System is a database, then you can use a database view or stored procedure to format data before it is returned. For example, you can convert Data fields to text and remove the time. External Lists display dates as text OOB, so you aren't loosing anything with this approach except the unwanted time information.
 
Create custom InfoPath or ASPX forms
Just like standard lists, External Lists support custom InfoPath and ASPX forms. InfoPath forms can use controls to completely change the user interface and add validation logic. ASPX forms support XSLT, which can be used to change URL fields into images.
 
Use XSLT and the External Data web parts
External Data web parts accept custom XSLT, which can be used in the same way as ASPX forms.
 
Use a FormatString property or RedererDefinition
In cases where fields can easily be converted to formatted text, use a FormatString property in the BDC Metadata Model to define how the field should be formatted. For complete control, a RendererDefinition property can reference a custom rendering class to create the formatted field. The following code shows a sample:
 

       <TypeDescriptor Name="BusinessAddress"

        TypeName="ComplexTypeConnector.Address, ComplexCustomerModel"

        IsCollection="false">

       <Properties>

        <Property Name="FormatString" Type="System.String">

         {0}, {1}, {2} {3}

        </Property>

       </Properties>

       <TypeDescriptors>

        <TypeDescriptor Name="Street" TypeName="System.String" />

        <TypeDescriptor Name="City" TypeName="System.String" />

        <TypeDescriptor Name="State" TypeName="System.String" />

        <TypeDescriptor Name="Zip" TypeName="System.String" />

       </TypeDescriptors>

      </TypeDescriptor>

 
Create a custom web part
You can take complete control over the rendering of an External List by writing a custom web part that calls the BDC Server Runtime API. The BDC Server Runtime API will return data from the External System, which can then be rendered in controls like an SPGridView.
 
Create custom field types/field controls
External Lists can use custom field types/field controls to render fields. Create the field types and field controls as normal and then associate them with fields in the BDC Metadata Model. The following code shows a sample:
 

       <TypeDescriptor TypeName="System.Int64" Name="LegacyMainframeID">

        <Properties>

         <Property Name="SPCustomFieldType" Type="System.String">

          BCSInt64Field

         </Property>

        </Properties>

       </TypeDescriptor>

 
Create a .NET Assembly Connector
When you create a .NET Assembly Connector, you control how the connections and operations are performed on the External System. You can also control how the data is formatted and returned to SharePoint. This allows you to format fields before they are returned and renderd in the External List.
 
 
Posted by Scot Hillier on 20-Sep-10
0 Comments  |  Trackback Url  |  Link to this post | Bookmark this post with:        
 

Links to this post

Comments