代码之家  ›  专栏  ›  技术社区  ›  Jebathon

Kendo网格服务器端筛选将空作为筛选对象发送到后端

  •  0
  • Jebathon  · 技术社区  · 6 年前

    使用Kendo AngularJS和ASP.NET MVC,我试图将网格的filters对象发送到后端。但是,即使我将serverFiltering设置为true,在前端生成的任何过滤器在请求中都是空的。

    enter image description here

    grid.dataSource = new kendo.data.DataSource({
        serverFiltering: true,
        transport: {
            read: {
                  url: "api/foo",
                  dataType: "json",
                  type: "POST"
                  }
         },
         schema: {
              data: "data", // records are returned in the "data" field of the response      
              total: "total"
        }
        });
    
    //set grid to filterable
    grid.filterable = {
        mode: 'row',
        operators: {
             string: {
                     contains: "contains"
                     }
         }
     };
    

    我看了一眼 similar question 但这对我没有帮助,因为我无法复制作为公认答案列出的解决方案

    1 回复  |  直到 6 年前
        1
  •  0
  •   Jebathon    6 年前

    在控制器端,“DataSourceRequest”以不同的方式映射表单值(例如检查前端发送的POST请求“filter”,而不是将“Filters”作为参数)。我不得不创建一个新的模型类来绑定适当的值