display all lists in a particular site collection

Sep 24, 2014 at 11:59 PM
I have a req to display all possible lists on a single page in SP

so far this is the only code which sorta works

http://itrob.be/sharepoint-get-all-lists-names-in-javascript-spservice-and-jquery/

$().SPServices({
           operation:"GetListCollection",
           async:false,
           completefunc: function(xData, Status) {
               $(xData.responseXML).find("List").each(function(){
                   listNames = $(this).attr("Title");
                   alert(listNames);
               })
           }
           })
1) it shows all type of lists even document type list , all I want it to show or display is
the custom list which I have created and once i create a new list it should show that on the same page

Thanks
D
Coordinator
Sep 25, 2014 at 9:36 AM
What you get back from GetListCollection gives you enough info to go on. You'll want to filter on the ServerTemplate attribute for the type of list you want to display.

For instance, if you want just the Custom Lists:
var p = $().SPServices({
  operation:"GetListCollection"
});
p.done(function() {
  $(p.responseXML).find("List").each(function(){
    var listName = $(this).attr("Title");
    if($(this).attr("ServerTemplate") === "100") {
      alert(listName);
    }
  });
});
Note that I've switched to using a promise so that the request won't tie up the browser.

M.
Sep 25, 2014 at 9:34 PM
Edited Sep 25, 2014 at 10:17 PM
Thanks M it worked

I know how to add an hyperlink to the display list(s) , but I what i want is when the user clicks on the hyperlink it should take the user to that particular list

var liHtml = "<li><a href='" + listNames + "'>" + listNames + "</a> </li>";
                $("#tasksUL").append(liHtml);
will using the GUID help ?

never mind . I figured it out

var list_URL = $(this).attr("DefaultViewUrl");

thanks for all you help
Coordinator
Sep 28, 2014 at 8:58 AM
No problem. I'm glad you figured it out.

M.