1

I'm encountering some problems with my Custom Type Field... It works, but I cannot make it display as I want inside my list! First of all I've overwrite the FieldValueType like this:

public override Type FieldValueType
{
    get { return (typeof(MultiLinkPicker)); }
}

Then I overwrite the GetFieldValueAsHtml to act as I want:

public override string GetFieldValueAsHtml(object value)
{

    string[] indirizzi = base.GetFieldValueAsText(value).Split(';');

    StringBuilder sb = new StringBuilder();
    string app = String.Empty;


    foreach (string s in indirizzi)
    {
        sb.Append("<a href=\"" + s + "\"> </a><br />");
    }

    return sb.ToString() + app ;
}

The problem is that SharePoint shows me in the list the whole text, not the links! In the column I find

<a href="..."> </a>

And not the link! How can I do to solve this problem? I tried overwriting other methods, but it doesn't work at all. Any suggesions?

1 Answer 1

3

you can use a custom xsl file that sets the disable-output-escaping of the column to "yes". This is explained in more detail in the following blogpost http://pholpar.wordpress.com/2010/09/11/external-list-example-demonstrating-net-connectivity-assembly-and-custom-field-type/

Summary:

  1. Open the display form of list in sharepoint designer
  2. Open the view you want to show html
  3. Select the column you want to show html
  4. On the bottom of the design view you can see kind of a breadcrumb with <xsl:value-of> at the end. Click on this <xsl:value-of> and choose edit tag
  5. Add the following text inside the tags "disable-output-escaping="yes""

This generates some xsl code which is added to the page/view. If you switch to the code view in sharepont designer you can see it.

In my case i just copied that xsl code and use it in a xsl which i use as the in a custom view.

Xsl File:

    <xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema"
            xmlns:d="http://schemas.microsoft.com/sharepoint/dsp"
            version="1.0"
            ....
    <xmlns:__designer=".... xmlns:ddwrt2="urn:frontpage:internal">
    <xsl:import href="/_layouts/xsl/main.xsl"/>
    <xsl:template name="FieldRef_Text_body.IconEdit" ddwrt:dvt_mode="body" match "FieldRef[@Name='IconEdit']" mode="Text_body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:param name="thisNode" select="."/>
   <xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping ="yes"/>
    </xsl:template>

Custom View:

<View DisplayName="All Items" DefaultView="FALSE" BaseViewID="1" Type="HTML" MobileView="TRUE" MobileDefaultView="TRUE"
        ImageUrl="/_layouts/images/generic.png" XslLink="main.xsl" WebPartZoneID="Main" WebPartOrder="0" Url="AllItems.aspx"
        SetupPath="pages\viewpage.aspx">
    <XslLink>MyCustomXsl.xsl</XslLink>
    <Method Name="ReadList" />
    <Query> ...

I hope this helps

Regards Tschüge

3
  • Thank you very much! Now that i have the code of XSL file and of the Cusom View, how can i use it to model my Custom Type so that it will automatically be configured?
    – Ziba Leah
    Nov 22, 2011 at 13:31
  • Don't you a specific list using that custom type? In my case i had one list so i just added the XslLink to the view of that list. I don't know how you can achieve that the xsl is used on all and every occurance of your custom type. sorry.
    – tschuege
    Nov 22, 2011 at 13:55
  • @ZibaLeah No, i copied the xsl transformation generated by SPDesigner as it was and copied it to my xsl file.
    – tschuege
    Nov 22, 2011 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.