0

I am trying to show all the document library links on the content editor web part in SharePoint 2013. I had written Jqeury for it and it worked fine on SharePoint 2010 but after migrating to 2013 this is not working. Can some one help me in figuring out what am I missing in here. I have uploaded the 2010 code..

enter image description here

<link href="/Test/Applications/SiteAssets/style/Table.css" rel="stylesheet" type="text/css" />

<script src="/Test/Applications/SiteAssets/jQuery/jquery-1.11.1.min.js"></script>
<script src="/Test/Applications/SiteAssets/jQuery/jquery-ui.min.js"></script>
<script src="/Test/Applications/SiteAssets/jQuery/jquery.SPServices-0.7.1a.min.js"></script>
<link  type="text/css" rel="stylesheet" href="/Test/Applications/SiteAssets/jQuery/jquery-ui.css" /> 
<link  type="text/css" rel="stylesheet" href="/Test/Applications/SiteAssets/jQuery/jquery-ui-1.9.0.custom.min.css" /> 
<script type="text/javascript" src="//cdn.datatables.net/1.10.2/js/jquery.dataTables.min.js"></script>
<script src="/Test/Applications/TestReleases/SiteAssets/JavaScript/security.js"></script>
<link  type="text/css" rel="stylesheet" href="/Test/Applications/TestReleases/SiteAssets/style/customMenu.css" />
<script src="/Test/Applications/SiteAssets/JavaScript/ApplicationManagedServices.js"></script>
<link rel="stylesheet" type="text/css" href="/Test/Applications/SiteAssets/style/controls-6E924A6.css">

<script type="text/javascript">

    var _clientContext = null;
    var _web = null;
    var _sitefullURL = null;
    var collList  = null;
    var txt = null;
    var _currentUser = null;
    var staffList = null;
    var staffListCollItems = null;
    var itemOrg = null;

    var orgList = null;
    var orgListCollItems = null;
    var itemAMSTeam = null;

 function initForm() {


        getUserInformation().done(function (userOb) {
            loggedinUserName = userOb.get_title();
            loggedinUserEmail = userOb.get_email();
            _currUserID = userOb.get_id();

            _clientContext = new SP.ClientContext.get_current();

            _web = _clientContext.get_web();
            _sitefullURL = window.location.protocol + "//" + window.location.host + _clientContext.get_url();
            ShowProgressAnimation();
            //getUserOrganization();
            //getListCollection();
                    getListCollection();
            $.when( getUserOrganization() ).done(function() {
                $.when( getAMSTeam() ).done(function() {

                    var itemTxt = document.getElementById('teamID');
                    itemTxt.innerHTML = itemAMSTeam;
                    setMenu();
                });
            });

        });
    }


 function getListCollection() {
        try {

            collList = _web.get_lists();
            _clientContext.load(collList);
            _clientContext.executeQueryAsync(function () { onQuerySucceeded(); }, function () { onQueryFailed(); });

        }
        catch (Error) {
            alert(Error.message);
        }



        function onQuerySucceeded(){
            var count = this.collList.get_count();
            var hiddenItems = ["Documents", "Images", "Pages", "Site Assets", "Site Pages", "Master Page Gallery"];

            //Loop through results and build table rows

                        var itemList = document.getElementById("ulMainGroup");
                        //getChildT("Home-icon.png",itemList, 'Home', '/Test/Applications/');
            createLinkCustom("Home-icon.png",itemList, 'Home', '/Test/Applications/');
            for (var x = 0; x < count ; x++) {
                         var title = this.collList.itemAt(x).get_title();
                           if(this.collList.itemAt(x).get_baseType() == 1 && findIndex(hiddenItems, title)  == -1){
                                if(title == 'Training Documents'){
                    createLinkCustom("dev_icon.png",itemList, this.collList.itemAt(x).get_title(), this.collList.itemAt(x).get_defaultViewUrl());
                                }else
                    {

                    createLinkCustom("Blank-Folder-icon.png",itemList, this.collList.itemAt(x).get_title(), this.collList.itemAt(x).get_defaultViewUrl()); //Blank-Folder-icon.png
                                }
               }
            }

            createLinkCustom("orange-add-list-48.png",itemList, 'Tasks', '/Test/Applications/TestReleases/Lists/Tasks/');
            createLinkCustom("orange-add-list-48.png",itemList, 'Schedules', '/Test/Applications/TestReleases/Lists/Schedules/');

            HideProgressAnimation();

        }

    function onQueryFailed() {alert(Error.message);}

}




    $(document).ready(function () {
        //ExecuteOrDelayUntilScriptLoaded(LoadSecurity, "sp.js");
/*
var liToMove = $('#zz17_TopNavigationMenuV4 div>ul').html();
var fullmenu = "<ul class='root static'><li class='static'><a class='static menu-item' title='Home' href='/Test/Applications/' accesskey='1'><span class='additional-background'><span class='menu-item-text'>Dosumentation Trainings</span></span></a><ul class='static'>"+ liToMove + "</ul></li></ul>";

$('#zz17_TopNavigationMenuV4 div>ul').html(fullmenu);*/
        ExecuteOrDelayUntilScriptLoaded(initForm, "sp.js");
        });
</script>
<table class ="mystyle"><tr><td><span id='idSpanText'></ span></td></tr></table>


<ul class="dfwp-column dfwp-list" style="width:100%" id="idMainMenu">
  <li class="dfwp-item">
    <div class="groupheader item medium" id="teamMainID">Menu</div>
    <ul class="dfwp-list" id='ulMainGroup'></ul>
</li>


</ul>

<div id="loading-div-background">
    <div id="loading-div"  >
      <img  src="/Test/Applications/SiteAssets/ajax-loader%20(1).gif" alt="Loading.."/>
      <h2 style="color:gray;font-weight:normal;">Please wait....</h2>
     </div>
</div>
  • I was using fiddler to find out any error and getting this "The property or field 'DefaultViewUrl' has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested" any idea what I am missing here. Can some one please help out. – SPLearner Mar 15 '18 at 20:02
  • Can anyone suggest on this? – SPLearner Mar 16 '18 at 14:47
0

Finally I resolved it. Changed Defaultviewurl() to get_serverRelativeurl()

createLinkCustom("dev_icon.png",itemList, this.collList.itemAt(x).get_title(), this.collList.itemAt(x).get_defaultViewUrl()); 
 createLinkCustom("Blank-Folder-icon.png",itemList, this.collList.itemAt(x).get_title(), this.collList.itemAt(x).get_defaultViewUrl()); //Blank-Folder-icon.png

and everything working as usual required.

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.