0

我正在使用 asp.net mvc4。对于我的观点,我使用剑道 ui GPL 版本进行设计,这里只使用剑道的 javascript。

<div id="grid" style="width:500px"></div>
         <script>
             $(document).ready(function () {
                 $("#grid").kendoGrid({
                     dataSource: {                             
                         transport: {
                             read: { url: "Movies/Index", dataType: "json" }
                         },
                         schema: {
                             model: {
                                 fields: {
                                     ID:{type:"number"},
                                     Title: { type: "string" },
                                     ReleaseDate: { type: "date" },
                                     Price: { type: "number" },
                                     Genre: { type: "string" }
                                 }
                             }
                         },
                         pageSize: 10,
                         serverPaging: true,
                         serverFiltering: true,
                         serverSorting: true,                           

                     },
                     height:230,
                     filterable: true,
                     columnMenu: true,
                    groupable: true,
                         sortable: true,
                         pageable: true,
                         columns: [
                             {
                                 field: "ID",
                                 width: 90,
                                 title: "ID"
                             }, {
                         field: "Title",
                         width: 90,
                         title: "Title"
                     }, 
                     {
                         field: "Genre",
                         width: 90,
                         title: "Genre"
                     }, {
                         width: 100,
                         field: "Price"
                     },  {
                         field: "ReleaseDate",
                         title: "ReleaseDate",
                         template: '#= kendo.toString(ReleaseDate,"dd MMMM yyyy") #'
                     }
                     ]
                 });
             });

并在我的控制器中使用 json 动作:

public JsonResult Index()
        {
            try
            {
                var ind = db.Movies.Select(a => new Models.Movie
                {
                    ID = a.ID,
                    Title = a.Title,
                    Genre = a.Genre,
                    Price = a.Price,
                    ReleaseDate = a.ReleaseDate
                }).OrderBy(a => a.Title);


                return this.Json(ind, JsonRequestBehavior.AllowGet);
            }catch(Exception)
            {
                throw;
                }
        }

但问题是数据没有进入我的视野。任何帮助是极大的赞赏。

4

0 回答 0