1

Newbie SharePoint 2010 question

I opened my View in SharePoint designer 2010

I've got a list and I was able to set linked item property on a column "Contribution"

<ViewFields>
<FieldRef Name="Edit"/>
<FieldRef Name="CONTRIBUTION" LinkToItem="TRUE"/>

Now the users wants to get into Edit Mode instead of Display. I googled and find similar sites like this :

http://sharepointweblog.blogspot.be/2013/10/sharepoint-open-list-item-directly-to.html

I did split screen Design/Preview in SharePoint designer 2010, do not see any code like. But the issue is I don't see code/word like below "FORM_DISPLAY" or "FORM_EDIT".

Change the HREF property to below property just change the “$FORM_DISPLAY” to “$FORM_EDIT”

So I how can I make this link click becomes in Edit mode, Why do I not see my

{$FORM_EDIT}&ID={$ID}&ContentTypeID={$thisNode/@ContentTypeId}

I also tried doing this with jQuery Content editor webpart, but this is not working either, the breakpoint hits the "each " but doesn't get into the function detail. When I click in debugger "$('.ms-vb2 a[href*="listform.aspx"]')" it returns an object.

<script type="text/javascript">
$(document).ready(function () {
// Change all display form links to edit form links
$('.ms-vb2 a[href*="listform.aspx"]').each(function () {
    var link = $(this).attr('href');
    link = link.replace("PageType=4", "PageType=6");
    $(this).attr('href', link);
});
});
</script>

The below code is added after discussion as requested:

 <a href="javascript:" onclick="javascript:ExpCollGroup('{$ViewCounter}-{$groupindex}{$groupindex2}', 'img_{$ViewCounter}-{$groupindex}{$groupindex2}',event, true);MakeViewLink();return false;">
            <img src="{$imagesrc}" border="0" alt="{$alttext}" id="img_{$ViewCounter}-{$groupindex}{$groupindex2}" />
                <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
            <xsl:value-of select="$fieldname" />
          </a>
        </xsl:when>
            <xsl:otherwise>
          <a href="javascript:" onclick="javascript:ExpCollGroup('{$ViewCounter}-{$groupindex}{$groupindex2}', 'img_{$ViewCounter}-{$groupindex}{$groupindex2}',event, false);MakeViewLink();return false;">
            <img src="{$imagesrc}" border="0" alt="{$alttext}" id="img_{$ViewCounter}-{$groupindex}{$groupindex2}" />
                <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
            <xsl:value-of select="$fieldname" />
          </a>

============================================================

$(document).ready(function() { MakeViewLink(); alert("in doc ready"); });

function MakeViewLink() { alert("makeview"); $('div[class^="ms-vb2"').find('a').each(function(){ var href = $(this).attr('href'); if(href != undefined) { href = href.replace('PageType=4','PageType=6'); $(this).attr('href', href); } });

}

  • Try to make any change (adding a space) and save the page. This will make the XSL visible in the current page. – Amal Hashim Oct 24 '14 at 12:18
  • I did in code and in design view.. no changes. – user3080110 Oct 24 '14 at 12:30
  • do you have jQuery files installed on your server? – Amal Hashim Oct 24 '14 at 12:35
  • just checking now... jquery is working, the reason why it was not working was because of grouping. I have 2 groups... Units then Documents. When I use grouping Jquery is not applying, when I removing the groups on the view then it works. But I need to apply groups. – user3080110 Oct 24 '14 at 12:57
  • If you have grouping then it wont work. Also if you have pagination then also the jQuery approach will fail. – Amal Hashim Oct 24 '14 at 13:02
0

Try below code

Without Grouping

$(document).ready(function() {
    $('div[class^="ms-vb"').find('a').each(function(){
      var href = $(this).attr('href');
      if(href != undefined) {
          href = href.replace('PageType=4','PageType=6');
          $(this).attr('href', href);
      }
    });
});

With Grouping

  1. Edit the view aspx page in designer (Edit in Advanced Mode)
  2. Look for javascript:ExpCollGroup(...);return false;"
  3. Change it to javascript:ExpCollGroup('...');MakeViewLink();return false;" (Keep the content inside ExpCollGroup
  4. Look for </WebPartPages:WebPartZone>
  5. Paste Below code

    $(document).ready(function() {
        MakeViewLink();
    }); 
    
    function MakeViewLink() {
        $('div[class^="ms-vb"').find('a').each(function(){
          var href = $(this).attr('href');
          if(href != undefined) {
              href = href.replace('PageType=4','PageType=6');
              $(this).attr('href', href);
          }
        });
    }
    
  6. Stop editing and refresh page
| improve this answer | |
  • no the query you gave is not working, mines is working, but it doesn't work if I do grouping. – user3080110 Oct 24 '14 at 13:01
  • sorry Corretion... yes, your jquery is working now, but not if I apply grouping on the list. I've 2 group fields, then jquery is not working. I mean it doesn't get in the edit mode. – user3080110 Oct 24 '14 at 13:07
  • sorry but, I don't see anything like "javascript:ExpCol.." in the code. 1) I Open SPD 2) I Open the List 3) Then I rightclick on the View (right part of screen) call CWEdit.aspx 4) I choose Eidt Advanced mode 5) then I goto Code View, but no code is there as you suggest. the below div is empty maybe therefore????? I don't knnow. <WebPartPages:WikiContentWebpart <Content><div> &nbsp;</div> </Content> </WebPartPages:WikiContentWebpart> – user3080110 Oct 24 '14 at 13:36
  • In the design mode, click on any of the list field heading and press space bar. Save. And then go to code view and check – Amal Hashim Oct 24 '14 at 13:38
  • ok we make progress :) now I see the XSL tags, but no javascript:ExpCollGroup even search only for ExpCollGroup but not found. – user3080110 Oct 24 '14 at 13:47

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.