如何在mvc中使用gndo版本的kendo ui网格

时间:2013-10-28 11:28:19

标签: asp.net-mvc kendo-ui kendo-grid

我正在使用asp.net mvc4。而对于我使用kendo ui GPL版本进行设计的观点,这里只使用了kendo的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;
                }
        }

但问题是数据没有进入我的视野。非常感谢任何帮助。

0 个答案:

没有答案