Microsoft Developer Network > Forenhomepage > SharePoint - Business Data Catalog > Business Data List web part, format field from database as hyperlink
Stellen Sie eine FrageStellen Sie eine Frage
 

BeantwortetBusiness Data List web part, format field from database as hyperlink

  • Dienstag, 23. Dezember 2008 14:36jandho TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    Hi,

    I have a BDC with an entity that selects fields from a table. One of the fields is the full pathname to a file, or it could be a hyperlink.
    When I display the entity in a Business Data List Web Part, all fields are displayed as text, without any formatting. I know the formatting can be modified using the XSL editor (under modify web part), I have found a sample with date-time format . Some basic formatting can also be done with de sharePoint designer, but nowhere have I found an example that allows me to format the column with the link as a clickable hyperlink.
    My strong points are sql server and .net , but not XSL , can anyone give me an example of how th eformatting needs to be done in XSL?

    tnx in advance


    Jan D'Hondt - Database and .NET development

Antworten

  • Dienstag, 6. Januar 2009 16:31jandho TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     BeantwortetEnthält Code
    Ben,

    thank you for the reply.

    this is what I cooked from your answer and some others that I found on the web.
    Remember, the XSL I am editing is for a Business Data List web part. My Datafield contains an absolute url. so I had to find out where in the XSL was the formatting of the cell values (not the headers).

    Original XSL

     

          <td class="ms-vb">
            <xsl:attribute name="style">
              <xsl:choose>
                <xsl:when test="$dvt_1_form_selectkey = @*[name()=$ColumnKey]">color:blue</xsl:when>
                <xsl:otherwise />
              </xsl:choose>
            </xsl:attribute>
            <xsl:variable name="fieldValue">
              <xsl:call-template name="LFtoBR">
                <xsl:with-param name="input">
                  <xsl:value-of select="@DocumentationLink" />
                </xsl:with-param>
              </xsl:call-template>
            </xsl:variable>
            <xsl:copy-of select="$fieldValue" />
          </td>

     

    Modified XSL

     

          <td class="ms-vb">
            <xsl:attribute name="style">
              <xsl:choose>
                <xsl:when test="$dvt_1_form_selectkey = @*[name()=$ColumnKey]">color:blue</xsl:when>
                <xsl:otherwise />
              </xsl:choose>
            </xsl:attribute>
              <a target="_blank" href="{@DocumentationLink
    }">
                  <xsl:value-of select="@DocumentationLink" />
               </a>

          </td>


    Jan D'Hondt - Database and .NET development
    • Als Antwort markiertjandho Dienstag, 6. Januar 2009 16:34
    •  

Alle Antworten

  • Dienstag, 30. Dezember 2008 19:02Ben Cline1MVPTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Enthält Code
    Sure, here is an example of how I formatted a field to show an image: http://social.msdn.microsoft.com/Forums/en-US/sharepointbdc/thread/d2b18c36-c5b4-43d3-bae2-d9fd2b491a29. In the web part properties you can see the default XSL and then find the field you want to modify.

    If you want to format it for a hyperlink and the field name is LinkUrl you can do it like this:

    <xsl:element name="a">     
       <xsl:attribute name="href"><xsl:value-of select="@LinkUrl" /></xsl:attribute>    
    </xsl:element>    
     

    The above example assumes the LinkUrl has the absolute path in it. If you need to append text to the value and LinkUrl is a relative path you could do something like this:

    <xsl:element name="a">     
                <xsl:attribute name="href">http://www.mysite.com/path/<xsl:value-of select="@LinkUrl" /></xsl:attribute>    
    </xsl:element>    
     

    Let me know if you have any questions on this, I would be glad to help.

    Thanks,
    If this answers your question, please use the "Answer" button to say so | Ben Cline
  • Dienstag, 6. Januar 2009 16:31jandho TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     BeantwortetEnthält Code
    Ben,

    thank you for the reply.

    this is what I cooked from your answer and some others that I found on the web.
    Remember, the XSL I am editing is for a Business Data List web part. My Datafield contains an absolute url. so I had to find out where in the XSL was the formatting of the cell values (not the headers).

    Original XSL

     

          <td class="ms-vb">
            <xsl:attribute name="style">
              <xsl:choose>
                <xsl:when test="$dvt_1_form_selectkey = @*[name()=$ColumnKey]">color:blue</xsl:when>
                <xsl:otherwise />
              </xsl:choose>
            </xsl:attribute>
            <xsl:variable name="fieldValue">
              <xsl:call-template name="LFtoBR">
                <xsl:with-param name="input">
                  <xsl:value-of select="@DocumentationLink" />
                </xsl:with-param>
              </xsl:call-template>
            </xsl:variable>
            <xsl:copy-of select="$fieldValue" />
          </td>

     

    Modified XSL

     

          <td class="ms-vb">
            <xsl:attribute name="style">
              <xsl:choose>
                <xsl:when test="$dvt_1_form_selectkey = @*[name()=$ColumnKey]">color:blue</xsl:when>
                <xsl:otherwise />
              </xsl:choose>
            </xsl:attribute>
              <a target="_blank" href="{@DocumentationLink
    }">
                  <xsl:value-of select="@DocumentationLink" />
               </a>

          </td>


    Jan D'Hondt - Database and .NET development
    • Als Antwort markiertjandho Dienstag, 6. Januar 2009 16:34
    •  
  • Dienstag, 6. Januar 2009 16:57Ben Cline1MVPTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    I was definitely referring to the values not the headers, which are found in a different section of the XSL entirely.
    If this answers your question, please use the "Answer" button to say so | Ben Cline
  • Donnerstag, 8. Januar 2009 13:13jandho TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    The solution I have shown above is for the values , not for the headers. I see a column headers like usual and the a series of rows with the cell values formatted as hyperlinks. 
    Jan D'Hondt - Database and .NET development