Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

i have try to editing xlstviewwebpart for editing customize.but havnt getting any clues for my scenario.

i want to change title link in edit mode instead of display mode in webpart pages.

this view display in webpart page

when link on title's link its render in display mode

like this:

enter image description here

so i want to directly open in Edit mode. any one guide me plz?

share|improve this question

2 Answers 2

up vote 9 down vote accepted

There are several ways to achieve this.

I think the most preferrable way is to create a computed field.

1. Computed field

The point is, actually there are 5 "Title" fields in any SharePoint list:

enter image description here

First stores the data, the other 4 are Computed and simply generate some HTML, using data from the first column.

You can use similar approach and add your own computed field into the list, and then add it to the list view.

To add a computed field, you can use AddFieldAsXml method.

Example of using AddFieldAsXml for Computed field creation:

P.S. Most safe way to address edit form is to use ListForm.aspx page, as follows:

/_layouts/listform.aspx?PageType=6&ListId={PUT-LIST-GUID-HERE}&ID=5

(PageType value goes from PAGETYPE enumeration)

2. XSL Transformation

Another option is to use XSLT capabilities of the XsltListViewWebPart. In this case, you need to write your xsl file, and attach it to the list view, for example by filling in SPView.XslLink property.

Example:

<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal" xmlns:o="urn:schemas-microsoft-com:office:office"> 

  <xsl:include href="/_layouts/xsl/main.xsl"/> 
  <xsl:include href="/_layouts/xsl/internal.xsl"/> 

  <xsl:param name="AllRows" select="/dsQueryResponse/Rows/Row[$EntityName = '' or (position() &gt;= $FirstRow and position() &lt;= $LastRow)]"/>
  <xsl:param name="dvt_apos">'</xsl:param>

  <xsl:template match="FieldRef[@Name='LinkTitle']" mode="Computed_LinkTitle_body">
      <xsl:param name="thisNode" select="." />
      <a>
          <xsl:attribute name="href">/_layouts/listform.aspx?PageType=6&amp;ListId=<xsl:value-of select="$List" />&amp;ID=<xsl:value-of select="$thisNode/@ID" /></xsl:attribute>
          <xsl:attribute name="onclick">
              SP.UI.ModalDialog.showModalDialog({
                url: '/_layouts/listform.aspx?PageType=6&amp;ListId=<xsl:value-of select="$List" />&amp;ID=<xsl:value-of select="$thisNode/@ID" />'
              }); return false;
          </xsl:attribute>
          <xsl:value-of select="$thisNode/@Title"/>
      </a>
  </xsl:template>
</xsl:stylesheet>

P.S. This code has been tested and works.

share|improve this answer
    
awesome solution!!! Thanx a lots for given guud direction as well as attach xsl script.Thanx for sharing your knowledge. –  jigs May 15 '12 at 9:29
    
Very nice explanation. –  Ashish Patel Oct 28 '12 at 3:00

Another possible option is if you open the view in designer and add your xsl elements there

Does anyone know anything about performance differences on the three ways on a large lists?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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