简体   繁体   中英

How do I bind the results of an AJAX GET call to a Kendo Grid?

Refer to the comment inside the AJAX done function below:

$("<div/>").appendTo(e.detailCell).kendoGrid({
        reorderable: true,
        resizable: true,
        dataSource: {
            transport: {
                read: function()
                {
                    $.ajax({
                        url: "http://x/y/api/Awards/directors/" + e.data.AwardTitleId,
                        type: "GET"
                    }).done(function()
                    {
                        //I'm not sure what to do here in order to bind the data returned by the GET to the grid.
                    });
                },
            },
            schema: {
                model: {
                    id: "namefirstlast",
                    fields: {
                        "namefirstlast": { editable: true, type: "string" },
                        "directorsequence": { editable: true, type: "number", validation: { min: 1 } },
                        "isonballot": { editable: true, type: "boolean" },
                        "concatenation": { editable: true, type: "string" },
                        "MoreNames": { editable: true, type: "number", validation: { min: 0 } },
                    },
                },
            }
        },
        columns: [
            { field: "namefirstlast", title: "Name", editor: namesAutoComplete },
            { field: "directorsequence", title: "Director Sequence", format: "{0:n0}" },
            { field: "isonballot", title: "On ballot?" },
            { field: "concatenation", title: "Concatenation" },
            { field: "MoreNames", title: "More names?", format: "{0:n0}" },
            { command: ["edit"], title: "&nbsp;", width: 100 }],
        sortable: true,
        sort: { field: "namefirstlast", dir: "desc" },
        editable: "inline",
        toolbar: [{ name: "create", text: "Add New Director/Recipient" }]
    });

Figured it out:

detailRow.find(".directorsOrRecipients").data("kendoGrid").dataSource.read();
detailRow.find(".directorsOrRecipients").data("kendoGrid").refresh();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM