2

例如,我有一个带有 model 的视图IEnumerable<Correspondence>。我想将它绑定到 KendoUI 网格。我应该怎么办?我试过了

    @model IEnumerable<Correspondence>
    <div id="Correspondence"></div>
    <script>
        $(document).ready(function () {
            $('#Correspondence').kendoGrid({
                dataSource: {
                        data: @Html.Raw(Json.Encode(Model)),
                        editable: { destroy: true },
                        batch: true,
                        pageSize: 15,
                        schema: {
                            model: {
                                id: "Id",
                                fields: {
                                    Subject: { type: "string" },
                                    CorrespondenceType: { type: "number" },
                                    SentDate: { type: "date" }
                                }
                            }
                        }
                    },
                    navigatable: true,
                    selectable: "row",
                    filterable: true,
                    sortable: true,
                    pageable: {
                        refresh: true,
                        pageSizes: true
                    },
                    columns: [
                        {
                            title: "Subject",
                            field: "Subject"
                        },
                        {
                            title: "Type",
                            field: "CorrespondenceType"
                        },
                        {
                            title: "Sent Date",
                            field: "SentDate",
                            format: "{0:MM/dd/yyyy}"
                        },
                        {
                            command: [{ name: "openCorrespondence", text: "Open", className: "k-grid-openLaboratory", imageClass: "k-icon k-i-maximize", click: Open },
                                { name: "deleteCorrespondence", text: "Delete", className: "k-grid-deleteLaboratory", imageClass: "k-icon k-delete", click: Delete },
                                { name: "EditCorrespondence", text: "Edit", className: "k-grid-editLaboratory", imageClass: "k-icon k-edit", click: Edit }],
                            title: "Action"
                        }
                    ]
                });
            }); // end ready
    </script>

但它不起作用。桌子甚至没有出现。请帮我。谢谢你。

已编辑!!!

4

1 回答 1

3

我已经解决了我自己的问题。因为我使用了命令列,所以我必须添加 3 个函数:OpenEditDelete。然后,网格显示成功。

于 2013-05-12T12:38:52.110 回答