Microsoft Developer Network > 포럼 홈 > SharePoint - Business Data Catalog > Business Data List web part, format field from database as hyperlink
질문하기질문하기
 

답변됨Business Data List web part, format field from database as hyperlink

  • 2008년 12월 23일 화요일 오후 2:36jandho 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    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

답변

  • 2009년 1월 6일 화요일 오후 4:31jandho 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨코드 있음
    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
    • 답변으로 표시됨jandho 2009년 1월 6일 화요일 오후 4:34
    •  

모든 응답

  • 2008년 12월 30일 화요일 오후 7:02Ben Cline1MVP사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     코드 있음
    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
  • 2009년 1월 6일 화요일 오후 4:31jandho 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨코드 있음
    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
    • 답변으로 표시됨jandho 2009년 1월 6일 화요일 오후 4:34
    •  
  • 2009년 1월 6일 화요일 오후 4:57Ben Cline1MVP사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    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
  • 2009년 1월 8일 목요일 오후 1:13jandho 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    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