How to add a custom button to allitems view of a custom list ?

Its just a list, and with only 1 view, i want to add a custom button on the view, which will navigate user to another page.

1 Answer 1


View pages are just web part pages.

You can edit the page add a button using a Content Editor Web Part above the list web part.


This may be the way to go. Looks like you can add javascript to the page. With javascript you can render anything.


You can declare a view within a List Definition with the following markup

<View BaseViewID="2" 
    <FieldRef Name="Title" />
  <Query />
  <Toolbar Type="Standard" />
  <JSLink Default="TRUE">~site/Scripts/ButtonRender.js</JSLink>

Notice the JSLink attribute at the bottom.

Create the corresponding javascript file.

In the JS, the header template can be customized, which is one option for adding a button.

(function () {
    // Initialize the variable that stores the objects.
    var overrideCtx = {};
    overrideCtx.Templates = {};

    overrideCtx.Templates.Header = "<div><button>Test Button</button><br /><#=ctx.ListTitle#>";

    // Set the template to the:
    //  Custom list definition ID
    //  Base view ID
    overrideCtx.BaseViewID = 2;
    overrideCtx.ListTemplateType = 10057;

    // Register the template overrides.


The default header can be maintained by using this changing the header definition line to (Source):

overrideCtx.Templates.Header = "<div><button>Test Button</button><br /><#=ctx.ListTitle#>" + RenderTableHeader(overrideCtx) + "</table>";

As noted in the linked post, the RenderTableHeader method prints the default table, but doesn't print the table close(Maybe?).

I have not tested this as I don't have a 2013 env in front of me, but this should get you close.

  • thank you, but I want to do it in visual studio with list defintion Aug 14, 2014 at 12:34
  • Please add more details to your answer to make it less dependent in the links. E.g. outline the steps needed Aug 14, 2014 at 12:52
  • datasheet view is not visible anymore pleazo pleazo helpo Aug 14, 2014 at 15:47
  • I assume you mean the edit button is gone (as well as the rest of the header?) Aug 15, 2014 at 12:39
  • Just wondering. It isn't easier to use a module instead? Aug 15, 2014 at 14:43

Your Answer

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

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