【问题标题】:How to read this Json to controller object? Kendo UI grid server filtering如何将此 Json 读取到控制器对象? Kendo UI 网格服务器过滤
【发布时间】:2012-08-08 19:42:39
【问题描述】:

我正在尝试过滤 Kendo UI 网格服务器端过滤器。开发人员工具在查询字符串中显示了这一点

/Home/GetUsmMessage?{"filter":{"logic":"and","filters" [{"field":"MessageId","operator":"eq","value":1}] },"group":[]} GET 200 应用程序/json

我创建了一个对象结构,以便将结构读取到对象

    public ActionResult GetUsmMessage(FilterContainer filter)
    {
        //Code to read the filter container
        return Json(jsonData, JsonRequestBehavior.AllowGet);
    }

过滤容器的对象结构:

public class FilterContainer
{
    public List<FilterDescription> filters { get; set; }
    public string logic { get; set; }
}
public class FilterDescription
{
    public string @operator { get; set; }
    public string field { get; set; }
    public string value { get; set; }

    public List<FilterDescription> filters { get; set; }
    public string logic { get; set; }
}

当我调试控制器功能时,它仍然给我一个空对象。请帮忙

【问题讨论】:

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


    【解决方案1】:

    得到答案...我忘记将请求类型添加为 Http 帖子 ....

    【讨论】:

      【解决方案2】:

      如果是 WebApi 控制器,您可以使用 [FromUri] 属性和 GET 动词:

          public HttpResponseMessage Get(
      [FromUri]IEnumerable<SortParameter> sort, 
      [FromUri]FilterContainer filter, 
      int take = 10, int skip = 0)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-01-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多