kendo grid ajax bind无法正常工作

时间:2013-11-16 09:31:08

标签: c# ajax razor kendo-grid

我按照kendo演示,我检查数据是要查看的数据的返回列表,但最后网格没有显示任何行。

查看

@(Html.Kendo().Grid<ProductListModel>()

    .Name("grid")  
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("RowTemplate_Read","Product").Type(HttpVerbs.Get))

    )        
    .Scrollable()
)

控制器

 [HttpGet]

        public ActionResult RowTemplate_Read([DataSourceRequest] DataSourceRequest request)

        { 
            var productList = GetAllProduct().Select(e => new ProductListModel{Name = e.NameChi, Id = e.Id });


            return Json(productList.ToDataSourceResult(request));
        }

以下是页面和错误视图:

http://postimg.org/image/dx0cyu5n1/ http://postimg.org/image/9ptdejo9t/


17-NOV-2013 最后我发现问题是DTO,我不能直接用它来绑定,谁能告诉我原因?!

DTO代码:

public class ProductDTO : DTO
    {

        [MaxLength(50)]
        public string NameChi { get; set; }

        [MaxLength(50)]
        public string NameEng { get; set; }

        public decimal Price { get; set; }

        public string DescriptionChi { get; set; }

        public string DescriptionEng { get; set; }

        public bool IsPublic { get; set; }

        [ForeignKey("Product_Brand")]
        public BrandDTO Brand { get; set; }

        [ForeignKey("Brand")]
        public int BrandId { get; private set; }

        public string MainPhotoPath { get; set; }

        [ForeignKey("ProductCategory")]
        public int ProductCategoryId { get; private set; }

        [ForeignKey("Product_ProductCategory")]
        public ProductCategoryDTO ProductCategory { get; set; }

        [ForeignKey("ProductType")]
        public int ProductTypeId { get; private set; }

        [ForeignKey("Product_ProductType")]
        public ProductTypeDTO ProductType { get; set; }

        public  List<PhotoDTO> PhotosPaths { get; set; }

        public  List<TagDTO> Tags { get; set; }

        public  List<GalleryDTO> Galleries { get; set; }

    }

0 个答案:

没有答案