Paul McCaskie
Paul McCaskie

Reputation: 477

SharePoint 2010 – Dynamic Columns in List View

I just wanted to check something before I plough more time into a problem I’m having, as I want to make sure I’m not trying to do something stupid or unfeasible. Currently I am working on a SharePoint project where I have created a list in Visual Studio, with various views. The requirements are that one of these views contains a number of calculations on data involving the current date, and the value of items over time. I am well aware of the Today problem, so do not want to store these pieces of data in the list, but I would like dynamically calculate the figures to show them on the list view.

The problem is I’m not sure if this can be done. Obviously I could hand craft a web part which in code creates a grid using the list data, but this isn’t ideal as I would like to include all of the out of the box list functionality. Is there a way to customise the list view page to add columns in say XSLT or jQuery? Can this be done in a Visual Studio Sandbox solution as we are trying not to use SharePoint Designer because it lacks source control and we would like to be able to deploy chunks of the system to a SharePoint site automatically?

I know this is a lot of questions but I’m pulling my hair out with this once, hence my asking. Thanks in advance.

Upvotes: 0

Views: 1784

Answers (1)

Stefan
Stefan

Reputation: 14880

You could create a custom field type. In SharePoint 2010 there is support for XSLT rendering:

Example from MSDN:

<xsl:template name="FieldRef_Text_body" ddwrt:dvt_mode="body" match ="FieldRef" mode="Text_body">
  <xsl:param name="thisNode" select="."/>
  <xsl:choose>
    <xsl:when test="@AutoHyperLink='TRUE'">
      <xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping ="yes"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$thisNode/@*[name()=current()/@Name]"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

Upvotes: 1

Related Questions