如何将SharePoint 2013列表绑定到Sharepoint 2013内部的Kendo Grid

时间:2018-10-24 19:09:12

标签: jquery data-binding kendo-ui kendo-grid sharepoint-2013

显示网格列和行,但其中没有数据。如果您单击这些URL,那么所有URL都会起作用并产生数据。我复制了我朋友的代码-他的工作。我所做的就是更改URL,变量名和字段以匹配我的不同网格。为什么不起作用?我没有收到任何错误消息。请帮助

$(document).ready(function () {
function grabList() {
    var dataContext = new SP.ClientContext("http://sharepointdev.spinsys.com/sites/PASBA/devplayground/Lists/Top10Rappers/AllItems.aspx");
    console.log(dataContext);
}
//ExecuteOrDelayUntilScriptLoaded(grabList, sp.js);
var Artists = new kendo.data.DataSource({
    type: "odata",
    transport: {
        read: {
            url: "http://sharepointdev.spinsys.com/sites/PASBA/devplayground/_api/lists/getbytitle(%27RapArtists%27)/items",
            dataType: "json",
            headers: { "Accept": "application/json;odata=verbose" },
            type: "GET"
        },
        create: {
            url: "http://sharepointdev.spinsys.com/sites/PASBA/devplayground/_api/lists/getbytitle(%27RapArtists%27)/items",
            type: "POST",
            dataType: "json"
        }
    },
    schema: {
        data: function (response) {
            return response.d.results;
        },
        model: {
            fields: {
                Rank: { field: "Rank", type: "number" },
                Artist: { field: "Artist", type: "string" },
                Albums: { field: "Albums", type: "number" },
                Grammys: { field: "Grammys", type: "number" }
            }
        }
    },
    batch: true
});
$("#grid").kendoGrid({
    dataSource: Artists,
    columns: [
        { title: "Rank", field: "id" },
        { title: "Artist", field: "Artist"},
        { title: "Albums", field: "Albums" },
        { title: "Grammys", field: "Grammys"},
        { command: "destroy" }
    ],
    schema: {
        model: {
            id: "ID",

        }
    },
    editable: true,
    scrollable: true,
    height: 400,
    selectable: true
});

0 个答案:

没有答案