none
Rendering Custom SPFieldMulticolumn RRS feed

  • Question

  • Hi,

    I need to implement a custom multicolumn field for SP 2010. I added three textboxes to the *.ascx control template.

    The first textbox is used as title field , the second is used for a hyperlink and the third as desciption field.

    Everythings works great except the rendering for the hyperlink value of second textbox in my list view.

    The values of my three textboxes should be rendered like this within the listview: ValueofTextBox1, http://valueoftextbox2.com, ValueofTextBox3

    I defined the displaypattern in my fldtypes_xx.xml without success. After some research I know that the html rendering for the list view is done within XSL Stylesheet. Can you provide me with some help, to render my multicolumn values as mentioned above?

    Thank you in advance

     

    Monday, May 17, 2010 11:37 AM

All replies

  • There is a guide here http://www.intheknow.it/customxsltfieldrendering.ashx on using XSLT to render a custom field type in a list view.

    Another way would be to add <Field Name="CAMLRendering">TRUE</Field> to your fldtypes_***.xml - this forces the field to use your renderpattern in a list view (although the XSLT way is far better in my opinion)


    Read my wiki at www.intheknow.it for more code and tips for developing with SharePoint 2007 & 2010
    Twitter: @starznet

    Technical Architect at Starznet Ltd. WSS/MOSS development and customisation with a primary focus on CMS.
    Monday, May 17, 2010 11:39 AM
  • Hi,

    I added <Field Name="CAMLRendering">TRUE</Field> to my fldtypes_***.xml with following code:

     <RenderPattern Name="DisplayPattern">
                <HTML><![CDATA[<a href=']]></HTML>
                <Column SubColumnNumber="0" HTMLEncode="TRUE"/>
                <HTML><![CDATA[' title=']]></HTML>
                <Column SubColumnNumber="1" HTMLEncode="TRUE"/>
                <HTML><![CDATA['>]]></HTML>
                <Column SubColumnNumber="2" HTMLEncode="TRUE"/>
                <HTML><![CDATA[</a>]]></HTML>
              </RenderPattern>

    Now I just get a string in my listview like: <a href="http://www.google.de" title="Google">Google Home</a>

    But what I need to display is: http://www.google.de, Google, Google home

    Do you know how to adapt the display this way?

    Thank you in advance

    Tuesday, May 18, 2010 11:42 AM
  • I would do this using the XSLT method, the CAMLRendering flag basically sends the value of the render pattern to the default XSLT, so it is likely the string created in the DisplayPattern is not being encoded correctly.


    Read my wiki at www.intheknow.it for more code and tips for developing with SharePoint 2007 & 2010
    Twitter: @starznet

    Technical Architect at Starznet Ltd. WSS/MOSS development and customisation with a primary focus on CMS.
    Tuesday, May 18, 2010 11:49 AM
  • Ok I tried to do this within XSL file.

    Now i have my string "value1,value2,value3" how can I access each substring?

    There is a function <xsl:value-of select="substring-before"> and <xsl:value-of select="substring-before"> . But this only works for 2 substrings, right?

    How can I access every substring?

    Thank you in advance.

    Tuesday, May 18, 2010 12:36 PM
  • Technically a different question now, this link may help you though: http://stackoverflow.com/questions/2850100/comma-separated-string-parsing-xslt

    It contains an answer to a similar question on how to split a comma delimited string. There may already be methods in the list view XSLT framework but I am yet to come across them.

    For now, something similar to what is in the link above should be sufficient.


    Read my wiki at www.intheknow.it for more code and tips for developing with SharePoint 2007 & 2010
    Twitter: @starznet

    Technical Architect at Starznet Ltd. WSS/MOSS development and customisation with a primary focus on CMS.
    Tuesday, May 18, 2010 2:33 PM