parthasarathy B

parthasarathy B

  • NA
  • 927
  • 108.5k

How to get library url in the below piece of code

Sep 19 2018 8:14 PM
Hi all,
          I am working on the task which retrieves all the subsites from the site collection and its lists and libraries names and its url to bind in  the div.I got all worked but i didn't get url of the document library which should be bind as a URL in the list name so that we can navigate to the libraries by clicking it.I posted my code below any help would be helpful. Thanks in advance.
 
  1. <script language="javascript" type="text/javascript">    
  2. $(document).ready(function() {    
  3.     
  4.     SP.SOD.executeFunc('sp.js''SP.ClientContext',getAllWebs);    
  5.     });    
  6.         
  7.     function getAllWebs(success,error)    
  8. {    
  9.    var ctx = SP.ClientContext.get_current();    
  10.    var web = ctx.get_site().get_rootWeb();    
  11.    var level = 0;    
  12.    jQuery("#tonydashboard").empty();    
  13.    var html4 ="<div class='tab'>";    
  14.        
  15.    var getAllWebsInner = function(web,success,error)     
  16.    {    
  17.       var ctx = web.get_context();    
  18.       var webs = web.getSubwebsForCurrentUser(null);     
  19.       //var webs = web.get_webs();    
  20.       ctx.load(webs,'Include(Title,Webs,ServerRelativeUrl,Lists)');    
  21.       ctx.executeQueryAsync(    
  22.         function(){    
  23.         for(var i = 0; i < webs.get_count();i++){    
  24.            var web = webs.getItemAtIndex(i);    
  25.            var webtitle = web.get_title();    
  26.            var weburl = web.get_serverRelativeUrl();    
  27.            jQuery("#tonydashboard").after("<div id='"+webtitle+"' alt='"+webtitle+"' style='display:none'></div>");    
  28.            this.listColl= web.get_lists();    
  29.            var listEnumerator = this.listColl.getEnumerator();    
  30.           while (listEnumerator.moveNext()) {    
  31.             debugger;    
  32.             var oList = listEnumerator.get_current();    
  33.             listInfo = 'Title: ' + oList.get_title() + ' BaseType: ' +     
  34.             oList.get_baseType() + '\n';    
  35.             //var listFullUrl = window.location.origin + oList.get_defaultViewUrl();    
  36.             var siteTitle=web.get_title();    
  37.             var listTitle=oList.get_title();    
  38.                 
  39.             $("[id='"+siteTitle+"']").append("<div onclick='window.open('newurl.html','mywindow');' style='cursor: pointer;'>"+listTitle+"</div>");    
  40.             console.log(listInfo);    
  41.          }    
  42.             
  43.         //var html3="<button class='tablinks' onclick='openCity(this)'>"+webtitle+"</button>";    
  44.         var html3="<input id='btnSearch' class='tablinks' type='button' onclick='openCity(this)' name='"+webtitle+"' value='"+webtitle+"'>";    
  45.         jQuery("#tonydashboard").append(html3);    
  46.                    if(web.get_webs().get_count() > 0) {    
  47.                    getAllWebsInner(web,success,error);    
  48.                 }       
  49.             }    
  50.          },    
  51.         error);    
  52.    };    
  53.     
  54.    getAllWebsInner(web,success,error);     
  55. jQuery("#tonydashboard").append('</div>');       
  56. }    
  57. </script>    
  58.     
  59. <div id="tonycontent">    
  60.     <!-- Dashboard -->    
  61.     <div id="tonydashboard" class="tonycontenttable">    
  62.         
  63.     </div>    
  64. </div>    
 

Answers (1)