4

The 'add new item' link which is always located at the end of the list. Is there a way that we can add a similar link at the top of the list?

0

6 Answers 6

3

Not possible by just configuring web part. Of course you could modify the Title Url of the web part to point to the Add new item URL, but I don't count that as a valid suggestion ;)

I would use javascript (jQuery) to search for the bottom Add new item link and inject similar to the correct position below the web part title.

Some web parts also allow you to edit the XSL of the web part. I haven't tried this myself, but you might be able to achieve the same in certain web parts using this method.

jQuery example (not on my dev machine now, so will share the idea at least):

  1. Find the Add new item node using ID and get it's html: $('table[summary='yourtablename'] td[class='ms-addnew']).html()
  2. Find the web part table, it should have "summary" attribute that might be easiest to find $('table[summary='yourtablename'])
  3. Append the Add new item TD you got from step 1 wherever you wish, or get the TR above that TD and append the row below/above column header row of the table
  4. You may want to change the ID attribute of the actual link to some other as there might be conflicts if you have two links with same ID attribute in HTML)
3
  • Hi Jussi, could u provide a example as to getting the "add new item" link using jquery
    – SandeshR
    Jan 31, 2012 at 15:23
  • Hi, edited the answer above.
    – Jussi Palo
    Feb 1, 2012 at 21:12
  • Thanks jussi for the reply.i will try it at work tomorrow
    – SandeshR
    Feb 2, 2012 at 3:55
4

You can edit the page to add a Content Editor Web Part up top and adjust the chrome type so that title / borders / etc don't display. Then edit the content of the web part to be a hyperlink to the same place as the other one.

2

You can keep the existing Add new item link at the bottom of the page and add an additional link above your list.

Add Content Editor web part above your list.

Copy the HTML markup from the existing Add new item link. You can see it with help of the F12 developer tools of internet explorer or inspect element of Firefox/Chrome.

Example:

<SPAN style="POSITION: relative; WIDTH: 10px; DISPLAY: inline-block; HEIGHT: 10px;    OVERFLOW: hidden" class=s4-clust><IMG style="POSITION: absolute; TOP: -128px !important; LEFT: 0px !important" alt="" src="/_layouts/images/fgimg.png"></SPAN>
<A id=idHomePageNewItem class=ms-addnew onclick='javascript:NewItem2(event, "http://{sharepointurl}/_layouts/listform.aspx?PageType=8&amp;ListId={E02C7414-96AC-4E3D-A00E-0693BE227241}&amp;RootFolder=");javascript:return false;' href="http://{sharepointurl}/_layouts/listform.aspx?PageType=8&amp;ListId={E02C7414-96AC-4E3D-A00E-0693BE227241}&amp;RootFolder=" target=_self>Add new item</A>

Paste the HTML markup into the Content Editor web part.

You may need to wrap the above code in a div and additional styling to it as needed.

2
  • but Mr.dhirschl,i wants the bottom link to be removed
    – Naresh Nemuri
    Dec 8, 2011 at 6:08
  • Change the toolbar type to No Toolbar in the XSLT List web part properties.
    – NLV
    Dec 12, 2011 at 13:52
1

Actually, the simplest approach and probably best solution is to simply link to the form on your site ending with NewForm.aspx. It looks even better if you add the + image in fron too. Example: New Issue Tracking Form

0

Assuming you have jQuery available in your environment. Here is a quick way to knock it out.

<script type="text/javascript" id="ms-addnew_js">
    $(document).ready(function () {
        $('.ms-addnew').filter(":last").hide();
    });
</script>
1
  • But the catch is that JQuery solutions always comes with a latency. You'll see the link for a minute. The best way is to edit the XSL underneath the List XSLT web part in the view page.
    – NLV
    Dec 12, 2011 at 13:52
0

This code must work with JQuery.

var $addnew = $('.ms-addnew');
($('#WebPartWPQ2').prepend('<br>')).prepend($addnew.html());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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