剑术网格表示JSON数据而不是实际的格 [英] Kendo grid is showing json data instead of the actual grid

查看:254
本文介绍了剑术网格表示JSON数据而不是实际的格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在剑道弹出窗口推出剑道格但不是电网表现,我得到的JSON数据。

这是从我的控制器code:

  [HTTPGET]
    公众的ActionResult读取([DataSourceRequest] DataSourceRequest要求,INT ID)
    {
        VAR模型= Service.FindOne(现金?时,X => x.Id == ID);
        VAR现金流=新的List<&流动GT;();        的foreach(在model.CashFlows变种CF)
        {
            VAR流量=新流
            {
                ID = cf.Id,
                由assetid = cf.Id,
                MortgageValue = cf.MortgageValue,
                年= cf.Year
            };
            cashflows.Add(流动);
        }        VAR的结果= cashflows.ToDataSourceResult(请求);        返回JSON(结果,JsonRequestBehavior.AllowGet);
    }

这是我在我的剑道查看。

  @(Html.Kendo()网格和LT。ViewModels.Finance.flows>()
。名称(网格)
.Columns(列=>
{
    columns.Bound(p值=> p.Id);
    columns.Bound(p值=> p.AssetId);
    columns.Bound(p值=> p.Year);
    columns.Bound(p值=> p.MortgageValue);
})
.DataSource(数据源=>数据源
    阿贾克斯()
    .Read(读=> read.Action(读,财经))
    .ServerOperation(假)
    .PageSize(5)

.Pageable()


解决方案

您需要更新命令return:

 返回JSON(result.ToDataSourceResult(要求),JsonRequestBehavior.AllowGet);

I'm trying to launch a Kendo grid in a Kendo popup Window but instead of the grid showing, I'm getting the json data.

This is the code from my controller:

[HttpGet]
    public ActionResult Read([DataSourceRequest]DataSourceRequest request, int id)
    {
        var model = Service.FindOne("Cashflows", x => x.Id == id);
        var cashflows = new List<flows>();

        foreach (var cf in model.CashFlows)
        {
            var flow = new flows
            {
                Id = cf.Id,
                AssetId = cf.Id,
                MortgageValue = cf.MortgageValue,
                Year = cf.Year
            };
            cashflows.Add(flow);
        }

        var result = cashflows.ToDataSourceResult(request);

        return Json(result, JsonRequestBehavior.AllowGet);
    }

This is what I have in my Kendo View.

@(Html.Kendo().Grid<ViewModels.Finance.flows>()
.Name("Grid")
.Columns(columns =>
{
    columns.Bound(p => p.Id);
    columns.Bound(p => p.AssetId);
    columns.Bound(p => p.Year);
    columns.Bound(p => p.MortgageValue);
})
.DataSource(dataSource => dataSource
    .Ajax()
    .Read(read => read.Action("Read", "Finance"))
    .ServerOperation(false)
    .PageSize(5)
)
.Pageable()
)

解决方案

You need to update the return command to:

return Json(result.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);

这篇关于剑术网格表示JSON数据而不是实际的格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆