简体   繁体   English

Kendo不显示任何数据,而且在mvc中显示空白行

[英]Kendo does not show any data Also it shows a blank row in mvc

Kendo does not show any data and it shows a blank row. Kendo不显示任何数据,而是显示空白行。 The grid reads from a controller method, which returns JSON. 网格从控制器方法读取,该方法返回JSON。 I have verified that the controller method is returning the correct, valid JSON, but the grid only shows the column titles, without any data in the table's rows with one blank row. 我已经验证了controller方法返回的是正确的,有效的JSON,但是网格仅显示列标题,而表的行中没有任何数据,其中包含一个空白行。 It shows a ReferenceError: kendo is not defined And at Console it shows Source map error: request failed with status 404 Resource URL: http://localhost:56644/Content/css/bootstrap-reboot.css Source Map URL: bootstrap-reboot.css.map 它显示了ReferenceError:未定义kendo,并且在控制台上它显示了源映射错误:请求失败,状态为404资源URL: http:// localhost:56644 / Content / css / bootstrap-reboot.css源映射URL:bootstrap-reboot .css.map

 public ActionResult GetProductsLists([DataSourceRequest]DataSourceRequest request )        
 {
       var product = (from u in this.unitOfWork.Product.Get()
              select new ProductViewModel
              {
                  product_id = u.product_id,
                  product_name = u.product_name
              });

    DataSourceResult result = product.ToDataSourceResult(request);
    var jsonResult = Json(result, JsonRequestBehavior.AllowGet);
    jsonResult.MaxJsonLength = int.MaxValue;
    return jsonResult;
}

 <div class="row">
        <div class="col-12">
            <div id="grid class="kendo-grid-custom">
                @(Html.Kendo().Grid<ProductViewModel>()
                                        .Name("gridProduct")
                                        .Columns(columns =>
                                        {
                                            columns.Bound(c => c.product_id).Title("Product Id").Filterable(true);
                                            columns.Bound(c => c.product_name).Title("Product Name").Filterable(true)                                         
                                            .HtmlAttributes(new { style = "height: 100%;" })
                                            .TableHtmlAttributes(new { @class = "text-nowrap" })
                                            .Scrollable()
                                            .Sortable()
                                            .Filterable()
                                            .Resizable(resizable => resizable.Columns(true))
                                            .Pageable(pageable => pageable
                                            .Refresh(true)
                                            .PageSizes(true)
                                            .ButtonCount(5)
                                            .DataSource(dataSource => dataSource
                                            .Ajax().Sort(x => x.Add("product_id").Ascending())
                                            .Read(read => read.Action("GetProductList", "Product"))
                                            .Model(m =>
                                            {
                                                m.Id(i => i.product_id);
                                            }).PageSize("20"))
                )

            </div>
        </div>
    </div>
 public ActionResult GetProductsLists([DataSourceRequest]DataSourceRequest request )        
   {
      var product = (from u in this.unitOfWork.Product.Get()
                  select new ProductViewModel
                  {
                      product_id = u.product_id,
                      product_name = u.product_name
                  });

        DataSourceResult result = product.ToDataSourceResult(request);
        var jsonResult = Json(result, JsonRequestBehavior.AllowGet);
        jsonResult.MaxJsonLength = int.MaxValue;
        return jsonResult;
    }

change your controller function using DataSourceRequest object and return the json result 使用DataSourceRequest对象更改控制器函数并返回json结果

Yes there is a bundling issue. Actually I gave the wrong Path of Kendo references thats 
why my kendo does not show any data. So I fix it and give it the right path i.e                                                                                 
bundles.Add(new StyleBundle("~/Content/kendo/css").Include(
            "~/Content/kendo/kendo.common.min.css",
            "~/Content/kendo/kendo.blueopal.min.css",
            "~/Content/kendo/kendo.custom.css"));

Also I crosscheck the path of the kendo script through the solution explorer as well as local disk of my computer.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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