0

I am using following to display all the items in content query webpart but only the folder is displayed. What am I missing? Sharepoint 2013

<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/knockout/knockout-3.1.0.js"></script>

<style type="text/css">
.knockOutTable td {
    background:#f7f7f7;
    padding:10px;
    vertical-align:top;  
    border:1px #fff solid;
}
.knockOutTable #td-alfa{
    font-weight:bold;
    width:20%;
}
.knockOutTable #td-beta, .knockOutTable #td-gamma{
    width:40%;
}
</style>

<script type="text/javascript">
var rootSite = "https://swe.sharepoint.com/";
var subSite = "knockout";
var results = [];

function LoadStuff(index) {

    $.ajax({
        url: rootSite + subSite + "/_api/web/lists/GetByTitle('KnockoutList')/items",
        method: "GET",
        headers: {"Accept": "application/json; odata=verbose"},

        success: function(data){
            results.push.apply(results, data.d.results);
            ko.applyBindings(results);
            },

        error: function (fn, status, error) {
            alert('Error:' + error);
            }

    });
}

$(function(){LoadStuff(0)})
</script>

<div>
    <div data-bind="template:{name:'KoList', foreach:results, as:'rows'}"></div>
    <script type="text/html" id="KoList">
        <table cellpadding="0" cellspacing="0" class="knockOutTable">
            <tr>
                <td id="td-alfa" data-bind="text:Title"></td>
                <td id="td-beta" data-bind="text:Introduction"></td>
                <td id="td-gamma" data-bind="text:Content"></td>
            </tr>
        </table>
    </script>
</div>
0

Liz,

Here is the post Display REST Data that will solve your issue.

Thanks

0

You need to use multiple REST API's calls to expand each of the folder's. Something like

/_api/web/lists/GetByTitle('KnockoutList')/Items(1)?$expand=folder

Where 1 is the ID of the folder

Another approach is to use SP.CamlQuery and use <View scope='RecursiveAll'>

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.