【问题标题】:Ajax binding kendo asp.net Mvc 3 only json displayedAjax 绑定剑道 asp.net Mvc 3 仅显示 json
【发布时间】:2012-08-18 00:11:46
【问题描述】:

json 结果只是显示在屏幕上,而不是填充网格。

public ActionResult BulkEdit([DataSourceRequest]DataSourceRequest request)
{        
    var NewAssets = db.TurnaroundDumps;
    DataSourceResult result = NewAssets.ToDataSourceResult(request)
    return Json(result, JsonRequestBehavior.AllowGet);
}

 那么在我看来:

@(Html.Kendo().Grid<PcInventory_v1_1.Models.TurnaroundDump>()
.Name("Grid")
.Columns(columns =>
{
    columns.Bound(p => p.AssetTag);
    columns.Bound(p => p.SerialNumber);
    columns.Bound(p => p.DeptId);
    columns.Bound(p => p.Location);
})
    .DataSource(dataSource => dataSource
        .Ajax() // Specify that the data source is of ajax type
        .Read(read => read.Action("BulkEdit", "Assets")) 
        // Specify the action method and controller name
    ).Pageable()
)

出了什么问题?

【问题讨论】:

  • 我认为这是因为 GET 请求。
  • 你在使用 kendo.aspnetmvc.js 吗?此外,为您的操作方法使用 [AcceptVerbs(HttpVerbs.Post)] 属性;尽可能避免 JsonRequestBehavior.AllowGet。不要忘记使用 kendo.aspnetmvc.js 否则你只会得到一个 json 返回。
  • 我们在论坛帖子中解决了这个问题。如果你喜欢,你可以链接它。
  • 您应该至少链接到论坛帖子,以便其他人在此问题的未来实例中使用。
  • 您好,请问这是怎么解决的?我有同样的问题.. Marius 我不包括 kendo.aspnetmvc.js 但我包括 kendo.aspnetmvc.min.js

标签: ajax json asp.net-mvc-3 kendo-ui


【解决方案1】:

我忘记返回视图了。

答案如下:

 public ActionResult BulkEdit()
    {
        return View();
    }

    [HttpPost]
    public ActionResult BulkEdit([DataSourceRequest]DataSourceRequest request)
    {
        var emp = db.TurnaroundDumps;


        DataSourceResult result = emp.ToDataSourceResult(request);


        return Json(result, JsonRequestBehavior.AllowGet);
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多