0

enter image description hereUsing SharePoint 2010, Having Custom List With 4 Columns, Now I am Using Content Query Web-part To Display List Data ,But Currently It Display Only First Column, SO How to Display Custom Fields in a SharePoint 2010 Content By Query Web Part

0

A Content By Query Web Part displays a dynamic view of content on a page

  • The Web Part has two major aspects: query and presentation. Query determines what content you want to show and presentation determines how you want to style and present the content.

The Content By Query Web Part uses XSL style sheets to render these columns by default.

  • If you want to query for custom content types and render specific columns from those content types in the Web Part, you must perform some minor customization in the .webpart file.

  • Edit the properties in the Web Part file to display custom fields. To access the .webpart file for the Web Part, on the Web Part's Edit menu, click Export.

  • In the .webpart file, locate the CommonViewFields property. Use this property to specify the additional fields that you want to display in the Web Part. Add the internal names of the columns and the type.

    property name="CommonViewFields" type="string">KB_x0020_Title,Text;Product;

  • This markup requests the Product column, to make the data in the columns available for rendering

  • Export the database to use it in your SharePoint

    -To change the presentation for given column you have to make changes in .xsl file

  • Hey Amit, m Not Understand the .Xsl Part, Image not Display Properly On Above Link, U Have Any Other Link Or Explain That Part To Me. – Akshay Dattatray Nangare Feb 18 '15 at 11:38
  • I have updated my answer .Please let me know if your query is resolved – Amit Kotha Feb 18 '15 at 11:54
  • Amit, Currently m Edit The Property in exported File <property name="CommonViewFields" type="string">InternalColumnNameGoesHere, FieldType</property> THen Upload Again In WebPArt, THen After That Download The ItemStyle.Xsl Then Add Some Line In It Above the </xsl:stylesheet> – Akshay Dattatray Nangare Feb 18 '15 at 12:15
  • <xsl:template name="CustomStyle" match="Row[@Style='VendorCustomStyle']" mode="itemstyle"> <html> <table width="100%"> <xsl:if test="count(preceding-sibling::*)=0"> <tr> <td width="8%" valign="top"><div class="item"><b>Name </b></div></td> </tr> </xsl:if> <tr> <td width="12%" valign="top"><div class="item"><xsl:value-of select="@Title" /></div></td> </tr> </table> </html> </xsl:template> – Akshay Dattatray Nangare Feb 18 '15 at 12:16
  • After that Save the file, go to the Style Library folder and upload the updated file to XSL Style Sheets folder and click on save button. Now right click the ItemStyle file and publish a Major Version. – Akshay Dattatray Nangare Feb 18 '15 at 12:18
0

1)Open ItemStyle.xsl

2)Add Template just like DisplayTemplate And give Proper Name(Currently given Name='MyFirst')

3)Add Variable After name="DisplayTitle"/> Currently i have two Columns MobileNo And Address

4)At The End of Code Add span

select="$MobileNo"

select="$Address"

5)Save ItemStyle.xsl and Checkin

6)Click on Edit WebPart ->Presentation->Fields to display: Here u can See Your Custom Column MobileNo & Address

Enter internal Name Of Column MobileNo inside MobileNo Custom Columns & Enter internal Name Of Column Address inside Address Custom Columns.

7)Click Ok

8)Done,now u can see all Custom Columns Data

u can see Total Code Below.(xsl:template name="MyFirst")

    <xsl:variable name="MobileNo"><xsl:value-of select="@MobileNo"></xsl:value-of></xsl:variable>
    <xsl:variable name="Address"><xsl:value-of select="@Address"></xsl:value-of></xsl:variable>

  <div class="item link-item">
    <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
    <a href="{$SafeLinkUrl}" title="{@LinkToolTip}">
      <xsl:if test="$ItemsHaveStreams = 'True'">
        <xsl:attribute name="onclick">
          <xsl:value-of select="@OnClickForWebRendering"/>
        </xsl:attribute>
      </xsl:if>
      <xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
        <xsl:attribute name="onclick">
          <xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
        </xsl:attribute>
      </xsl:if>
      <xsl:value-of select="$DisplayTitle"/>
    </a> - <span><xsl:value-of select="$MobileNo"></xsl:value-of></span>
    <span><xsl:value-of select="$Address"></xsl:value-of></span>

  </div>
</xsl:template>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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